The objetive of this code is to take the same actions in multiple WorkFlowWorkItems, for example:
I´m trying to make a massive approval using the "WorkflowWorkItemActionManager" class. However there is an issue.
void clicked()
{
WorkFlowWorkItemTable workItem, workItemUpdate, workItemSend;
MultiSelectionHelper helper;
WorkflowWorkItemActionDialog workflowWorkItemActionDialog;
//Inicialización de atributos
helper = MultiSelectionHelper::construct();
helper.parmDatasource(workflowWorkItemTable_ds);
workItem = helper.getFirst();
//Ejecución dialogo
if (workItem.RecId != 0)
{
workflowWorkItemActionDialog = WorkflowWorkItemActionDialog::construct(workItem,
WorkflowWorkItemActionType::Delegate,
new MenuFunction(menuitemActionStr(WorkflowLineItemResubmit), MenuItemType::Display));
workflowWorkItemActionDialog.run();
if (workflowWorkItemActionDialog.parmIsClosedOK())
{
// Condition is Rejected because Status is changed in Returned inside Approval Event Handler.
while (workItem.RecId != 0 && workItem.Status == WorkFlowWorkItemStatus::Pending)
{
select firstOnly workItemSend
where workItemSend.RecId == workItem.RecId;
try
{
WorkflowWorkItemActionManager::dispatchWorkItemAction(workItemSend,
workflowWorkItemActionDialog.parmWorkflowComment(),
workflowWorkItemActionDialog.parmTargetUser(),
WorkflowWorkItemActionType::Delegate,
menuItemDisplayStr(WorkflowWorkListAcceptanceMassive),false);
//Actualizamos el registro
ttsBegin;
select forUpdate workItemUpdate where workItemUpdate.RecId == workItem.RecId;
workItemUpdate.Status = WorkFlowWorkItemStatus::Completed;
workItemUpdate.update();
ttsCommit;
}
catch(Exception::Error)
{
throw error(strfmt("Error en la acción masiva"));
}
workItem = helper.getNext();
}
info("Delegación masiva finalizada");
// Refrescar el DataSource
workflowWorkItemTable_ds.research();
}
}
}