/// The MyWorkflowTypeSubmitManager menu item action event handler.
/// </summary>
public class MDLWorkflowTypeSubmitManager
{
public static void main(Args args)
{
// TODO: Write code to execute once a work item is submitted.
// Variable declaration.
BankAccountTrans bankAccountTrans;
PaymReference paymReference;
WorkflowStatusHandler workflowStatusHandler;
recId recId = args.record().RecId;
WorkflowCorrelationId workflowCorrelationId;
ConcurrencyModel concurrencyModel;
container recIds = conNull();
BankAccountStatement bankAccountStatement; // Ensure BankAccountStatement is defined
workflowTypeName workflowTypeName = workFlowTypeStr("WorkflowType");
// Initial note is the information that users enter when they
// submit the document for workflow.
WorkflowComment initialNote = "PleaseProvideABriefDescriptionorJustificationForThisWorkflowSubmission";
WorkflowSubmitDialog workflowSubmitDialog;
workflowSubmitDialog = WorkflowSubmitDialog::construct(args.caller().getActiveWorkflowConfiguration());
workflowSubmitDialog.run();
{
recId = args.record().RecId;
// Get comments from the submit to workflow dialog.
initialNote = workflowSubmitDialog.parmWorkflowComment();
FormDataSource ds = args.caller().dataSource();
ds.markAllLoadedRecords();
Map bankAccountMap = new Map(Types::String, Types::Container);
bankAccountTrans != null;
bankAccountTrans = ds.getNext() as BankAccountTrans)
{
if (bankAccountTrans)
{
// Group transactions by bank account
recIds = bankAccountMap.exists(bankAccountTrans.AccountId) ? bankAccountMap.lookup(bankAccountTrans.AccountId) : conNull();
recIds = conIns(recIds, conLen(recIds) + 1, bankAccountTrans.RecId);
bankAccountMap.insert(bankAccountTrans.AccountId, recIds);
}
}
try
{
MapIterator it = new MapIterator(bankAccountMap);
while (it.more())
{
BankAccount bankAccount = it.key();
recIds = it.value();
bankAccountTrans = BankAccountTrans::findByRecId_CN(firstRecId,false);
{
workflowCorrelationId = Workflow::activateFromWorkflowType(workflowTypeName, bankAccountTrans.RecId, initialNote, NoYes::Yes);
// Update the workflow state for each transaction in the group
for (int i = 1; i <= conLen(recIds); i++)
{
bankAccountTrans = BankAccountTrans::findByRecId_CN(conPeek(recIds, i),true);
if (bankAccountTrans.RecId != 0)
{
bankAccountTrans.MDLWorkflowState = MDLBankAccountWorkflowState::Submitted;
bankAccountTrans.update();
}
}
}
}
ttscommit;
info("SubmittedToWorkflow");
catch (exception::Error)
{
info("@MDLLabel:ErrorOnWorkflowActivation");
}
FormRun callerForm = args.caller();
if (callerForm)
{
callerForm.updateWorkflowControls();
callerForm.dataSource().reread(); // Refresh the data source.
callerForm.dataSource().refresh();
}
}
}

Report
All responses (
Answers (