AX 2012 Create Custom Workflow Microsoft Dynamics AX
AX 2012 Create Custom Workflow Microsoft Dynamics AX
In Microsoft Dynamics AX, workflow is structured and based on user interaction and system
automation of business data.
I have Student Fee Collection Table and School Administration wants Approval Process,
If fee is pending then they are not allow for next semester etc.
Base Enums
(1) Create “CustFreeInvoiceWFApprovalStatus” base enums for the workflow approval status
Create “FStatus” base enums for the workflow approval status
Field Datatype
Id Integer
Name String
Fee Real, Extended Datatype= AmountMST
FStatus Enum, Enum Type= FStatus
Enum,Enum Type=
WorkflowStatus
CustFreeInvoiceWFApprovalStatus
Override Method on “studen�able” Table
boolean ret;
if(this.FStatus==FStatus::Inreview)
ret=true;
return ret;}
After the workflow type is created, add code for the workflow events.
// Variable declaration.
WorkflowCorrelationId workflowCorrelationId;
WorkflowSubmitDialog workflowSubmitDialog;
studen�able stable;
//CustInvoiceLine custInvoiceLine;
// Opens the submit to workflow dialog.
workflowSubmitDialog
=WorkflowSubmitDialog::construct(args.caller().getActiveWorkflowConfiguration());
workflowSubmitDialog.run();
if (workflowSubmitDialog.parmIsClosedOK())
recId = args.record().RecId;
stable = args.record();
note = workflowSubmitDialog.parmWorkflowComment();
try
�sbegin;
workflowCorrelationId
=Workflow::activateFromWorkflowType(workflowTypeName,recId,note,NoYes::No);
stable.WorkflowStatus =CustFreeInvoiceWFApprovalStatus::Submi�ed;
info(“Submi�ed to workflow.”);
�scommit;
catch(exception::Error)
args.caller().updateWorkFlowControls();
{
studentwftSubmitManager SubmitManager =new studentwftSubmitManager();
SubmitManager.submit(args);
studen�able stable;
RecId SRecId;
SRecId =_workflowEventArgs.parmWorkflowContext().parmRecId();
�sBegin;
stable.WorkflowStatus =CustFreeInvoiceWFApprovalStatus::Completed;
stable.FStatus=FStatus::Approve;
stable.update();
�sCommit;
studen�able stable;
RecId SRecId;
SRecId =_workflowEventArgs.parmWorkflowContext().parmRecId();
�sBegin;
stable.WorkflowStatus =CustFreeInvoiceWFApprovalStatus::Pending;
stable.FStatus=FStatus::Pending;
stable.update();
�sCommit;
}
studen�able stable;
RecId SRecId;
SRecId =_workflowEventArgs.parmWorkflowContext().parmRecId();
�sBegin;
stable.WorkflowStatus =CustFreeInvoiceWFApprovalStatus::Cancellation;
stable.FStatus=FStatus::Cancel;
stable.update();
�sCommit;
***************************************************************************
Workflowenabled=Yes ,
workflowdatasource= studen�able
workflowtype= studentwft
Click Next.
studen�able stable;
RecId SRecId;
SRecId=_workflowElementEventArgs.parmWorkflowContext().parmRecId();
�sBegin;
stable.WorkflowStatus =CustFreeInvoiceWFApprovalStatus::Completed;
stable.FStatus=FStatus::Approve;
stable.update();
�sCommit;
studen�able stable;
RecId SRecId;
SRecId=_workflowElementEventArgs.parmWorkflowContext().parmRecId();
�sBegin;
stable.WorkflowStatus =CustFreeInvoiceWFApprovalStatus::Cancellation;
//stable.FStatus=FStatus::Cancel
stable.update();
�sCommit;}
studen�able stable;
RecId SRecId;
SRecId=_workflowElementEventArgs.parmWorkflowContext().parmRecId();
�sBegin;
stable.WorkflowStatus =CustFreeInvoiceWFApprovalStatus::ChangeRequested;
stable.update();
�sCommit;
studen�able stable;
RecId SRecId;
SRecId=_workflowElementEventArgs.parmWorkflowContext().parmRecId();
�sBegin;
stable.WorkflowStatus =CustFreeInvoiceWFApprovalStatus::Rejected;
stable.FStatus=FStatus::Cancel;
stable.update();
�sCommit;
studen�able stable;
RecId SRecId;
SRecId=_workflowElementEventArgs.parmWorkflowContext().parmRecId();
�sBegin;
stable.WorkflowStatus =CustFreeInvoiceWFApprovalStatus::Rejected;
stable.update();
�sCommit;
}
public void started(WorkflowElementEventArgs _workflowElementEventArgs)
//WorkflowElementStartedEventHandler
studen�able stable;
RecId SRecId;
SRecId=_workflowElementEventArgs.parmWorkflowContext().parmRecId();
�sBegin;
stable.WorkflowStatus =CustFreeInvoiceWFApprovalStatus::PendingApproval;
stable.FStatus=FStatus::Pending;
stable.update();
�sCommit;
Blog at WordPress.com.