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.

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'".


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.