web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Custom approval workflow error: FormRun object does not have method

(0) ShareShare
ReportReport
Posted on by 45

Hi,
I'm trying to create a custom approval Workflow related to a custom table.
I've followed the guide of "Extending Microsoft Dynamics 365 for Operations Cookbook Chapter 14".
The guide made me create a new workflow Type, a new workflow approval, a new manual workflow task.
It help me to hook up the workflow to the user interface and than to create a workflow design.
Following the guide, when I finished I found that a "workflow" button appeared in my custom form. Clicking on it, it shows me the menu item I inserted in my code(the one called "CAI_PaymMatrixWFSubmitMenuItem").
The problem is that when I push it the system gives me the error "Error executing code: FormRun object does not have method 'getActiveWrokflowConfiguration'".

Looking at the code of the main class it crashed when _args.caller() try to call the method getActiveWrokflowConfiguration. (See code Below)

public class CAI_PaymMatrixWFSubmitManager 
{
    public static void main(Args _args)
    {
        RefRecId recId;
        CompanyId companyId;
        RefTableId tableId;
        WorkflowComment comment;
        WorkflowSubmitDialog dialog;
        WorkflowVersionTable version;
        
        recId = _args.record().recId;
        tableId = _args.record().TableId;
        companyId = _args.record().dataAreaId;
        
        if (tableId != tableNum(CAI_CustItemPaymMatrix) || RecId == 0)
        {
            throw Error(strFmt("@SYS19306", funcName()));
        }
        FormRun workflowDialog = _args.caller();
        
        version = workflowDialog.getActiveWrokflowConfiguration(); <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"Error executing code: FormRun object does not have method 'getActiveWrokflowConfiguration'"
        
        dialog = WorkflowSubmitDialog::construct(version);
        dialog.run();
        
        if (dialog.parmIsClosedOK())
        {
            comment = dialog.parmWorkflowComment();
        
            Workflow::activateFromWorkflowConfigurationId(version.ConfigurationId, recId, comment, NoYes::No);
        }
        
        CAI_PaymMatrixWFEventHandler::SetStatus(_args.record().RecId, CAI_CustItemPaymMatrixApprovalStatus::Waiting);
        
        if (FormDataUtil::isFormDataSource(_args.record()))
        {
            FormDataUtil::getFormDataSource(_args.record()).research(true);
        }
        
        _args.caller().updateWorkflowControls();
    }
}

Searching the entire project I cannot found this method so I thought that the guide could be incomplete. I went in AOT and tried to follow the same code of the PurchTableTemplate.

Cattura1.PNGCattura1b.PNG
Trying to copy all the elements in this workflow type I copyed the menuitem and form PurchTableWorkflowDropDialog, and the class PurchTableWorkflowDropDialogFormAdaptor, and I added them my form.
Form CAI_PaymMatrixWorkflowDropDialog contains the method getActiveWrokflowConfiguration and I hoped to resolve the problem calling the workflow through it.
The code of the class CAI_PaymMatrixWFSubmitManager is the same (code above again) but _args.caller() now is my workflowDialog CAI_PaymMatrixWorkflowDropDialog that have the method required.
But clicking to the newly created button even with the second method I obtain the same error!

So in this moment I have two buttons in my form that both throw me the same error "Error executing code: FormRun object does not have method 'getActiveWrokflowConfiguration'".

Cattura2.PNGcattura3.PNG
Can anyone help me to solve this problem?

p.s. the guide in the book don't tell to create a workflowDropDialog or a WorkflowDropDialogFormAdaptor, so I don't think it is the right way to follow, if I am mistaken please tell me.

I have the same question (0)
  • Andrea Casagrande Profile Picture
    45 on at
    RE: Custom approval workflow error: FormRun object does not have method

    You are right, thanks a lot!!!

  • Verified answer
    WillWU Profile Picture
    22,361 on at
    RE: Custom approval workflow error: FormRun object does not have method

    Hi Andrea,

    First of all, you said you copyed the menuitem and form PurchTableWorkflowDropDialog, and the class PurchTableWorkflowDropDialogFormAdaptor, but the method in your code is getActiveWrokflowConfiguration(),

    not getActiveWorkflowConfiguration(), please check it.

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

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Sohaib Cheema Profile Picture

Sohaib Cheema 814 User Group Leader

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 798 Super User 2025 Season 2

#3
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 622

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans