You have violated the AgreementHeaderIdx by creating another record with the same Agreement and LineNumber fields as another record. I don't understand why you're reading an existing record, changing a few fields, and then doing another .insert() of that buffer. That's a terrible practice that is only going to cause you problems. If you intend to insert a new record, start with .clear(), set all of the required fields, and then .insert() it. Ultimately if you're going to create records through code, you have to mimic what the UX would do very closely, or the records won't work the same or at all.
↧