-
-
Save jofme/76effa3bb1a6ce06c2751721091fb9bb to your computer and use it in GitHub Desktop.
wfBulkDelegation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void clicked() | |
| { | |
| WorkFlowWorkItemTable workItem, workItemUpdate, workItemSend; | |
| MultiSelectionHelper helper; | |
| WorkflowWorkItemActionDialog workflowWorkItemActionDialog; | |
| // Initialization of attributes | |
| helper = MultiSelectionHelper::construct(); | |
| helper.parmDatasource(workflowWorkItemTable_ds); | |
| workItem = helper.getFirst(); | |
| // Dialog execution | |
| 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 the status is changed to Returned inside the 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 | |
| ); | |
| // Update the record | |
| ttsBegin; | |
| select forUpdate workItemUpdate | |
| where workItemUpdate.RecId == workItem.RecId; | |
| workItemUpdate.Status = WorkFlowWorkItemStatus::Completed; | |
| workItemUpdate.update(); | |
| ttsCommit; | |
| } | |
| catch (Exception::Error) | |
| { | |
| throw error(strfmt("Error in the bulk action")); | |
| } | |
| workItem = helper.getNext(); | |
| } | |
| info("Bulk delegation completed"); | |
| // Refresh the DataSource | |
| workflowWorkItemTable_ds.research(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment