Untuk membuat fungsi yang melakukan approval atas Sales Order tertentu maka bisa menggunakan kode dibawah ini:
WorkflowWorkItemTable wfItem;
SalesTable so;
so = SalesTable::find(<Nomor SO>);
Workflow::activateFromWorkflowType(workFlowTypeStr(<Nama workflow>), so.RecId, "Accept by x++", false, "<nama user AX>");
select wfItem
where wfItem.RefTableId == so.TableId && wfItem.RefRecId == so.RecId
&& wfItem.UserId == curUserId()
&& wfItem.Status == WorkflowWorkItemStatus::Pending;
if (wfItem) {
WorkflowWorkItemActionManager::dispatchWorkItemAction(
wfItem,
"Auto Approve by system",
curUserId(),
WorkflowWorkItemActionType::Complete,
menuitemActionStr(<Nama Menu Approval workflow yang digunakan>),
false);
}
Berdasarkan blog: How to approve workflow by Code | Mohammad Aamir Shakil (wordpress.com)
Tidak ada komentar:
Posting Komentar