Thursday, 10 March 2016

How to delete duplicate records through ax 2012

To delete duplicate records from salesTable or any other table through ax 2012 by x++ code you  can write code in AX job.

Set fieldSet = new set(Types::Integer);

DictIndex  IndexName  = new DictIndex(tablenum(SalesTable),indexnum(SalesTable,SalesIdx));

int i;
;
if(IndexName.numberOfFields())
{
for(i=1;i<=IndexName.numberOfFields();i++)
{
fieldSet.add(IndexName.field(i));
}

ReleaseUpdateDB::indexAllowDup(IndexName);
ReleaseUpdateDB::deleteDuplicatesUsingIds(SalesTable),0,fieldSet);
ReleaseUpdateDB::indexAllowNoDup(IndexName):
}

info("Duplicate Records deleted successfully");

No comments:

Post a Comment