Sunday 28 April 2013

AIF - Add operation update to LedgerGeneralJournal standard Document Service

Hi all, after 2 weeks vacations in Spain and 1 week course in Prague (Dynamics Ax Perfomance Workshop) I had really no time to write something new. So here we are.

Some month ago I had used the standard AIF Document Service for Ledger Journal in order to create new journals throught AIF. Everything worked perfect but last week I needed to improve this so I could be able to add lines to a journal that already exists throught AIF.

Everything looked ok but I realiced that the operation "update" was no activated by default and making it available have some tricky things that I want to share here.

First. We have to update the LedgerGeneralJournalService using the "Update document service" tool adding the methods "update" and "findKeys" and selecting the regeneration of the supporting classes.

 
Second. It is recomendable also to modify the Query AxdLedgerGeneralJournal establishing the property Update in the datasource LedgerJournalTable with value "Yes" so we allow the update on the datasource provided by the query.
 
Third. It is possible that we need to update the method "updateList" of the class AxdLedgerGeneralJournal. On default the update is not implemented so we would receive a message "operation not implemented", adding instead of the error message the code below would allow the update.
 
 
 
Fourth. One of the tricky things of the XML Message that we need to format for updating throught AIF is that we need to provide a DocumentHash of the document that we want to update. This value we could get if we realice a read operation with AIF but in my case I wanted to get the DocumentHash value without the need to call the read operation. In this link it is explained how we could do that:
 

 
And last we create the XML Message with the appropiate format for the Document Service. Where we specify the EntityKey which will be used to look for the JournalNum we want to update, the DocumentHash for the document and we specify that we want to update the entity LedgerJournalTable but create the entities LedgerJournalTrans (we want to add lines to an existing journal)
 
 
 These are the steps required to add lines to an existing journal throught AIF, something relatively easy but with small things that could make you lose a lot of time until you get it working. More info about updating data with AIF we can find here:
 
 
As always I finish with a wonderful photo. This time from the lovely city of Prague where I could attend the Dynamics Ax Perfomance Workshop :-)
 
 

1 comment:

  1. hi. Very handy and just what I need thanks. However i've not managed to complete it fully, In part 4 of your comments, you don't really go into specifics about how to pass the documentHash that we generate from the class we make into the inbound XML. How did you achieve this thanks?

    ReplyDelete