Added an update operation to InventItemService AIF service and getting exceptions

610 views Asked by At

To my surprise, I didn't find standard update and delete operations on InvenItemService. So in order to fullfill our client's requirements, I ran the AIF update wizard and added these two operations. I thought its easy and found the process of doing that very quick. Before doing that, I set the update property of the AxdItem query to Yes. Later, while debugging the update operations, I figured I had to modify the updateList() and Update() methods on AxdItem class as accordingly to provide method definitions.

public AifResult updateList(    AifEntityKeyList _entityKeyList,
                                AifDocumentXml _xml,
                                AifEndpointActionPolicyInfo _actionPolicyInfo,
                                AifConstraintListCollection _constraintListCollection)
{
    //throw error(strFmt("@SYS94920"));
    return super(_entityKeyList, _xml, _actionPolicyInfo, _constraintListCollection);
}
AifResult update(   AifEntityKey _entityKey ,
                    AifDocumentXml _xml,
                    AifEndpointActionPolicyInfo _actionPolicyInfo,
                    AifConstraintList _constraintList)
{
    //throw error(strFmt("@SYS94920"));
    return super(_entityKey, _xml, _actionPolicyInfo, _constraintList);
}

Now while trying to update an existing item in AX, I am getting following AIF exception.

Cannot edit a record in Item sales order settings (InventItemSalesSetup). The operation cannot be completed, since the record was not selected for update. Remember TTSBEGIN/TTSCOMMIT as well as the FORUPDATE clause.

Then I changed the update property of all the child data sources on AxdItem Query and re-ran the wizard. Ran CIL again and getting the following exception now.

Cannot edit a record in Item sales order settings (InventItemSalesSetup). An update conflict occurred due to another user process deleting the record or changing one or more fields in the record.

Any suggestions/ideas?

I have tried several things and spent too much time but failed.

1

There are 1 answers

0
Aliaksandr Maksimau On

Seems like you trying update the record that already has been deleted in method removeDefaultItemOrderSetup of AxdItem class

enter image description here

This will give you a hint what happens https://dynamicsuser.net/ax/f/developers/72116/aif-update-cannot-be-run-twice