пятница, 17 июня 2016 г.

What is the difference between Table.data() and buf2buf methods AX 2012


Hi all,
while creating a duplicate or copy of a record , generally we use table.data() method , for passing each  field one by one. The only problem with data() method is it would copy the system fields  also line ModifiedBy, CreatedBy etc, hence if we are inserting data across companies , we can't use data() method.

So what should be the solution for this?
Dynamics Ax also provides one more generic method buf2buf(_SourceRecord,_TargetRecord) , the only difference between Buf2Buf() and data() method is that buf2buf() doesn't copy system fields, which we need :-) 

So for intercompany data inserting, we should use buf2buf() method with changeCompany() method.

Looking forward to your comments.