PurchFormLetter_PackingSlip.update error

Hello,

I’m trying to receive good using PurchFormLetter class but got this error:

“Cannot create a record in Purchase order - update table (PurchParmTable). Purchase order: [My Purch order]
The record already exists.”

The order mentioned in the error message isn’t the purchase order used to receive good.

Here the test code:

PurchFormLetter_PackingSlip _PurchFormLetter_PackingSlip;

PurchTable _PurchTable;

ttsBegin

_PurchTable = PurchTable::find(“14-4918”);

_PurchFormLetter_PackingSlip = PurchFormLetter::construct(DocumentStatus::PackingSlip);

_PurchFormLetter_PackingSlip.showQueryForm(

false);

_PurchFormLetter_PackingSlip.update(_PurchTable,

“Bolla1”, systemDateGet(),PurchUpdate::RegisteredAndServices);

ttsCommit;

I have tryed another code but get the same error:

Purchtable Purchtable;

PurchFormLetter purchFormLetter;

PurchTable = PurchTable::find(

“14-4908”);

purchFormLetter = purchFormLetter::construct(DocumentStatus::PackingSlip);

purchFormLetter.update(purchTable,

“Bolla1”,systemDateGet(),PurchUpdate::RegisteredAndServices,AccountOrder::None,false,false);

I’m using AX 2012 R2 CU6

Thanks in advance for your help

The error means that you’re trying to data to database that’s causing a conflict on a unique index. But them code you showed doesn’t explain what’s wrong.

What’s the method where the error is thrown from? Go there and compare the data that you’re trying to put into database with what’s already there.

Thanks Martin for your help

I was answering to this post to say “I found the solution”…

I have deleted some records in the “purchparmtable” for my purchase order. these records had the field “parmjobstatus” = 1 and a description for an error in the field “log”. This purchase order is in invoced staus and is very old !

Dante.