Morten Lehrmann's Dynamics AX Blog

Morten Lehrmann's Dynamics AX Blog

About the Blog

The Blog gathers issues I have found useful during my work with Dynamics AX

Dynamics AX 2009 AIF

TipsPosted by Morten Lehrmann 2014-01-09 09:49:53
Adding DocuRefs to Query AxdPurchaseRequisition


When adding the DocuRef table to Query AxdPurchaseRequisition for use by AIF you may experience that the Documents you export from AIF does not include the new DocuRef entries.

The reason for this may be found in class AxdPurchaseRequisition method initQuery:

query.dataSourceTable(tablenum(DocuRef),1).findRange(fieldnum(DocuRef,TypeId)).value(vendFormletterDocument.DocuTypePurchOrder);
query.dataSourceTable(tablenum(DocuRef),2).findRange(fieldnum(DocuRef,TypeId)).value(vendFormletterDocument.DocuTypePurchOrder);


The tricky thing is the constants 1 and 2. They are described here:
http://msdn.microsoft.com/en-us/library/query.datasourcetable.aspx
Although it is not described how to numbering works.
However, the issue is that depending on where in the AxdPurchaseRequisition query you add DocuRef you may need to renumber these.

In my case changing 2 to 3 did the trick:

query.dataSourceTable(tablenum(DocuRef),1).findRange(fieldnum(DocuRef,TypeId)).value(vendFormletterDocument.DocuTypePurchOrder);
query.dataSourceTable(tablenum(DocuRef),3).findRange(fieldnum(DocuRef,TypeId)).value(vendFormletterDocument.DocuTypePurchOrder);