≡ Menu




Workflow resubmit code snippet dynamics ax 2012

Recently I wrote the code for Custom workflow for resubmit.  It took me half an hour to explore out of box code for resubmit.

While working in ERP, we have to daily learn new things and handle new situation.

Most of resubmit functionality is done through a lot of inheritance and much complex way.  Finally I found simplest resubmit code from “LedgerJournalWFApprResubmitToWF” class. I modified that code snippet, that works for me. Here is complete resubmit code. You have to update the resubmit event handler class generated by Workflow Approval Wizard as follow

public static void main(Args _args)
{
recID recID = _args.record().RecId;
tableId tableId = _args.record().TableId;
tableName tableBuffer = _args.record();
WorkflowWorkItemTable workItem = _args.caller().getActiveWorkflowWorkItem();
WorkflowWorkItemActionDialog workflowWorkItemActionDialog;
if (workItem.RecId > 0)
{
try
{

workflowWorkItemActionDialog = WorkflowWorkItemActionDialog::construct( workItem,
WorkflowWorkItemActionType::Resubmit,
new MenuFunction(_args.menuItemName(),_args.menuItemType()));
workflowWorkItemActionDialog.run();

if (workflowWorkItemActionDialog.parmIsClosedOK())
{
if ( tableName.WorkflowStatus == WorkflowStatus::ChangeRequest)
{
workItem = _args.caller().getActiveWorkflowWorkItem();
WorkflowWorkItemActionManager::dispatchWorkItemAction( workItem,
workflowWorkItemActionDialog.parmWorkflowComment(),
workflowWorkItemActionDialog.parmTargetUser(),
WorkflowWorkItemActionType::Resubmit,
_args.menuItemName(),
false);

tableName.WorkflowStatus= WorkflowStatus::Submitted;
ttsbegin;
tableName.dataSource().write();

ttscommit;
}
else
{
throw Exception::Error;
}
}
}

catch(Exception::Error)
{
throw error(strfmt("Can not resubmit some error occur"));
}
}
// Make the form refresh its common workflow UI controls.
_args.caller().updateWorkflowControls();
}

 

{ 0 comments… add one }

Leave a Comment