Replace \ Delegate Workflow User

With this piece of Code we can delegate Workflow from One User to another Using X++

Here I am taking example of Purchase Requistion


static void waj_replaceWorkflowUser(Args _args)
{
workflowtrackingstatustable workflowtrackingstatustable;
workflowtrackingtable workflowtrackingtable;
PurchReqTable purchreqTable;
WorkflowWorkItemTable workItem;
WorkflowStepTable workFlowStepTableSequence, workFlowStepTable;
WORKFLOWTRACKINGCOMMENTTABLE WORKFLOWTRACKINGCOMMENTTABLE;
purchreqTable = purchreqTable::findPurchReqId('PR-010454');
select workItem order by RecId desc
where workItem.RefTableId == tableNum(purchReqTable) &&
workItem.RefRecId == purchreqtable.recid &&
workItem.Status != WorkFlowWorkItemStatus::Completed &&
workItem.UserId == 's.Wajahat'; // slect user to replace
{
info(strFmt('%1', workItem.RefRecId));
}

WorkflowWorkItemActionManager::dispatchWorkItemAction(workItem,’Delegated’,’Ali’,WorkflowWorkItemActionType::Delegate,’PurchReqDelegate’,false);
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s