I have a requirement where I need to approve multiple lines in LedgerPeriodCloseProjectTask table at once using the Approval button in Workflow.
I also wrote a code for submitting a multiple records to workflow which is working fine!
The issue is in Approval. Its not Approving even after the Workflowstatus of the Line changes to approve! When I check the View history button in workflow its shows as it is still pending!
Sharing my code snippet:
class ABCD_CloseTaskWorkflowTypeApprovalManager
{
public static void main(Args args)
{
// TODO: Write code to execute once a work item is submitted.
FormDataSource periodClosetask_ds;
LedgerPeriodCloseProjectTask customWorkflowTable;
WorkflowWorkItemTable workflowWorkItemTable;
WorkflowComment note = "";
WorkflowSubmitDialog workflowSubmitDialog;
WorkflowCorrelationId workflowCorrelationId;
//multiSelectHelper = MultiSelectionHelper::construct();
periodClosetask_ds = FormDataUtil::getFormDataSource(args.record());
WorkflowTypeName workflowTypeName = workFlowTypeStr("ABCD_CLoseTaskWorkflowType");
//Opens the submit to workflow dialog.
if (periodClosetask_ds.anyMarked())
{
customWorkflowTable = args.record();
// Get comments from the submit to workflow dialog.
note = "Note check !";
for(customWorkflowTable = periodClosetask_ds.getFirst(true)? periodClosetask_ds.getFirst(true) : periodClosetask_ds.cursor();customWorkflowTable;customWorkflowTable = periodClosetask_ds.getNext())
{
try
{
if (customWorkflowTable.ABCD_WorkFlowStatus == ABCD_CloseTaskWorkFlowStatus::Submitted)
{
select firstonly workflowWorkItemTable
where workflowWorkItemTable.Type == WorkflowWorkItemType::WorkItem
&& workflowWorkItemTable.Status == WorkflowWorkItemStatus::Pending // this should be Pending
&& WorkflowWorkItemTable.RefTableId == tableNum(LedgerPeriodCloseProjectTask)
&& WorkflowWorkItemTable.RefRecId == customWorkflowTable.RecId;
WorkflowWorkItemActionManager::dispatchWorkItemAction(workflowWorkItemTable,note,curUserId(),WorkflowWorkItemActionType::Complete,menuItemActionStr(ADCG_CloseTaskWorkflowApprovalApprove),"WorkflowApproval");
}
}
catch (Exception::Error)
{
error("Error on workflow Approval !");
}
}
}
periodClosetask_ds.reread();
periodClosetask_ds.research(true);
periodClosetask_ds.refresh();
}
}
Thanks in advance!