Tuesday, June 18, 2013

AX 2012 AIF cannot set field value from .net application

I was working with one of the AIF document services in Dynamics AX 2012. I was trying to create general journal record from .net application but I noticed that few of my field values were not getting saved in AX. AIF will not throw any error, records were getting created but few fields were missing values even I provided the values.

For example:
ledgerJournalTrans.AmountCurCredit  = Convert.ToInt64(500.00);
           
I was trying to set the Credit value like above but I could not. I then found that we can set the specified attribute for such fields to true and then AIF will consider to set the values for these fields. See example below.

ledgerJournalTrans.AmountCurCreditSpecified = true;

When I added this statement, everything started to work as expected.