Axapta V/s Me

Yet another blog for Dynamics 365 for Finance and Operations. This blog primarily targets the technical readers. I will be sharing my experience with Dynamics AX using code snippets, errors, and solutions, Tips, and tricks.

Merging two Table Records

Merging two Table Records

Hi guys,
some times we need to merge two records within one line of table,
so to do this you can use following code, here for example i am using VendTabel and try to merge two vendors whose a/c no is 5001 and 5002 within 5001.

//we will explore how to correct such a situation by merging two records including
//all their related transactions. For the demonstration, we will merge two vendor accounts 5001
//and 5002 into a single one, that is, 5001.

static void VendAccountMerge(Args _args)
VendTable vendTable;
VendTable vendTableDelete;
PurchJournalAutoSummary jourSummary;

delete_from jourSummary
where jourSummary.VendAccount == #vendDelete;
select firstonly forupdate vendTableDelete
where vendTableDelete.AccountNum == #vendDelete;
select firstonly forupdate vendTable
where vendTable.AccountNum == #vend;

Be Careful to use this job/Query coz it directly effect your data base

No comments:

Post a Comment


Note: Only a member of this blog may post a comment.