Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Unanswered

Unable to open the workflow

(1) ShareShare
ReportReport
Posted on by 4
Hi,
 
I had created the custom workflow but now when the submitter submits the workflow the approver is unable to open it but he is receiving an exception Buffer for call of BankReconciliation is not specified.  See the code below 
 
/// <summary>
/// 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
        
        // Hardcoded type name
        workflowTypeName workflowTypeName = workFlowTypeStr("WorkflowType");
        // Initial note is the information that users enter when they
        // submit the document for workflow.
        WorkflowComment initialNote = "PleaseProvideABriefDescriptionorJustificationForThisWorkflowSubmission";
        WorkflowSubmitDialog    workflowSubmitDialog;
        // Opens the submit to workflow dialog.
        workflowSubmitDialog = WorkflowSubmitDialog::construct(args.caller().getActiveWorkflowConfiguration());
        workflowSubmitDialog.run();
        if (workflowSubmitDialog.parmIsClosedOK())
        {
            recId = args.record().RecId;
            // Get comments from the submit to workflow dialog.
            initialNote = workflowSubmitDialog.parmWorkflowComment();
            FormDataSource ds = args.caller().dataSource();
            ds.markAllLoadedRecords();
           
            ds = args.caller().dataSource();
            ds.markAllLoadedRecords();
            // Collect transactions by bank account
            Map bankAccountMap = new Map(Types::String, Types::Container);
            for (bankAccountTrans = ds.getFirst() as BankAccountTrans;
            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);
                }
            }
            ttsbegin;
            try
            {
                MapIterator it = new MapIterator(bankAccountMap);
                while (it.more())
                {
                    BankAccount bankAccount = it.key();
                    recIds = it.value();
                    
                    recId firstRecId = conPeek(recIds, 1);
                    bankAccountTrans = BankAccountTrans::findByRecId_CN(firstRecId,false);
                    if (bankAccountTrans)
                    {
                        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);
                            // Ensure the record is selected before update
                            if (bankAccountTrans.RecId != 0)
                            {
                               
                                bankAccountTrans.MDLWorkflowState = MDLBankAccountWorkflowState::Submitted;
                                bankAccountTrans.update();
                            }
                            
                        }
                        
                        
                    }
                    it.next();
                }
                ttscommit;
                // Send an Infolog message.
                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();
            }
           
        }
    }
}
 
Thanks & Regards
Lasya
  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,359 Super User 2024 Season 2 on at
    Unable to open the workflow
    Hi Lasya,

    In the coding, I don't see directly anything related to "BankReconciliation". I suggest you using the debugger to find the culprit.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

News and Announcements

Announcing Category Subscriptions!

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,359 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans