Показать сообщение отдельно
Старый 16.11.2018, 16:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,643 / 848 (80) +++++++
Регистрация: 28.10.2006
d365technext: Compare Records D365FO & AX 2012
Источник: http://d365technext.blogspot.com/201...o-ax-2012.html
==============





How to compare two records buffer field to field.



publicstaticcontainer compareRecords(Common _record1, Common _record2)
{
SysDictTable dictTable =new SysDictTable(_record1.TableId);
SysDictField dictField;
FieldId fieldId, extFieldId;
container ret;
int i, j;
;


if(_record1.TableId!= _record2.TableId)
returnconNull();


for(i=1; i<=dictTable.fieldCnt(); ++i)
{
fieldId = dictTable.fieldCnt2Id(i);
dictField =new SysDictField(_record1.tableId, fieldId);


if(!dictField.isSystem())
{
for(j=1; j<= dictField.arraySize(); ++j)
{
extFieldId = fieldId2Ext(fieldId, j);


if(_record1.(extFieldId)!= _record2.(extFieldId))
{
ret +=[extFieldId, _record1.(extFieldId), _record2.(extFieldId)];
}
}
}
}


return ret;
}




For Demo purpose you can use below code in job/runnable class.


static void demoCompareRecords(Args _args)
{
VendTable vendTable_1 = VendTable::find('ABC');
VendTable vendTable_2 = VendTable::find('XYZ');

container con;
int i;
;

con = MyClass::compareRecords(vendTable_1 , vendTable_2 );

for (i=1; i
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.