Using SysDa Framework to implement delete operation in D365FO.
Views (521)
Hi,
In this post will showcase the code where we can use SysDa Framework to perform the delete operation on a table based on matching criteria.
Note:CG_SysDaQueryDelete is a runnable class.
class CG_SysDaQueryDelete{ /// <summary> /// SysDaQueryObject - Implementing SysDaDeleteObject and SysDaDeleteStatement. /// </summary> /// <param name = "_args">The specified arguments.</param> public static void main(Args _args) { LedgerJournalTable ledgerJournalTable; ledgerJournalTable = LedgerJournalTable::find("JB002"); info(strFmt("Before deletion. Ledger Journal: %1", ledgerJournalTable.JournalNum)); new SysDaDeleteStatement().execute(new SysDaDeleteObject(CG_SysDaQueryDelete::buildQuery("JB002"))); ledgerJournalTable = LedgerJournalTable::find("JB002"); info(strFmt("After deletion. Ledger Journal: %1", ledgerJournalTable.JournalNum)); } static SysDaQueryObject buildQuery(LedgerJournalId _journalId) { LedgerJournalTable ledgerJournalTable; ledgerJournalTable.skipDataMethods(true); ledgerJournalTable.skipDeleteActions(true); SysDaQueryObject sysDaQuery = new SysDaQueryObject(ledgerJournalTable); sysDaQuery.whereClause(new SysDaEqualsExpression (new SysDaFieldExpression(ledgerJournalTable, fieldStr(LedgerJournalTable, JournalNum)), new SysDaValueExpression(_journalId))); return sysDaQuery; } }Output:https://drive.google.com/open?id=1gHYL1O59Mh-8FI3_USHlooN6Cg0WKuOK
Regards,
Chaitanya Golla

Like
Report
*This post is locked for comments