Share This Post

Dynamics AX Updates

Dynamics AX Workflows Creation

Microsoft Dynamics AX Workflows define how a business document flows through the system and indicates who must process and approve it. The workflow functionality in the Microsoft Dynamics AX helps ensure that documents are processed and approved in a consistent and efficient manner. Read on to understand the workflow system in the Microsoft Dynamics AX and see how you can configure, extend, and use it.

Custom Dynamics AX Workflows

Below mentioned are the elements integral to the custom workflow functionality in Dynamics Axapta:

Workflow category

When you create the MS Dynamics AX Workflows, it must be assigned to a workflow category. The workflow category indicates if the particular workflow type is available in a specific module. If an appropriate workflow category does not already exist, you must then create one.

Workflow query

You can create a query to retrieve the data by using the query classes.

Workflow type

To add the workflow support for a document in Microsoft Dynamics AX, you must create a workflow type. The workflow type can then be used to create the workflow configurations. Workflow types should be created to define:

  • Workflow documents
  • Workflow categories
  • Tasks and approvals for the workflow
  • Event handlers such as the workflow started, completed, configuration data change, and canceled
  • A SubmitToWorkflowMenuItem

Workflow elements

Any Dynamics AX Workflows consists of certain elements that define the task or the approval process. Mentioned below are some workflow elements:

  • Base enum: To define the workflow state
  • New field in the table: To maintain the workflow status as per table record
  • canSubmitToWorkflow() method to the table: To check if the record should be submitted to the workflow or not
  • Workflow properties on the form: To set created workflow elements on workflow property of the related form
  • Display the menu items: To create new workflows on the list page
  • Form: To perform the workflow activities on the form

Creating Custom Workflows

Below is the process to create a custom workflow for the sales type where the sales order will be submitted for the approval if the credit limit for the customer related to the sales order is exceeded.

1. First of all, make sure that the batch jobs that handle workflow execution are running.

If the batch jobs are not running, they can be started from System Administrator >> Setup>> Workflow >> Workflow infrastructure configuration.

Follow the Dynamics AX Workflows infrastructure wizard and set batch groups for all process.

Dynamics AX Workflows

Setup Workflow

2. Create workflow category

  • Expand Workflow Categories node in AOT >> Workflow.
  • Create New Workflow Category
  • Set the namelabel, and module properties for the newly created workflow category
Set name, label, and module properties

Set name, label, and module properties

3. Create query

  • Expand the Queries node in AOT
  • Click on New Query
  • Set the properties like Title and Description on the newly created query
  • Expand the newly created query
  • Add the main data source
  • Set the dynamic property of field node of the added data source to Yes
New Query

New Query

4. Create a workflow type

  • Expand Workflow Type node in AOT >> Workflow
  • Create New Workflow Type using workflow type wizard
  • Follow the wizard and set the workflow type namecategory (created in step 2), query(created in step 3) and document menu item (display menu item of form on which the workflow will be attached)
  • On clicking next, the wizard will show the list of objects that are going to be created. A new development project with the new elements will be created.
Workflow Type

Workflow Type

5. Create Base Enum

  • Expand the Base Enums node in AOT >> Data Dictionary
  • Create New Base Enum for workflow states
  • Set properties of the newly created enum
  • Add elements for workflow state to enum (i.e. not submitted, submitted, approved, rejected).
Create Base Enum

Create Base Enum

6. New field in the table

  • Select the table (on which the workflow will work) from AOT >> Data Dictionary >> Tables
  • Add the new enum type field and set enum type property to enum created in the previous step
  • Compile and synchronize the table.
Compile and synchronize the table

Compile and synchronize the table

7. canSubmitToWorkflow() method to table

  • Expand the method node on table (on which the workflow will work)
  • Add/modify the canSubmitToWorklfow() method to check whether the record should be added to the workflow or not. This method contains the code which defines eligibility of record to submit it to workflow
  • Sample code

boolean canSubmitToWorkflow(str _workflowType = ”)


amountMST creditBalance;

custTable custTable;


if (!this.CreditLimitApprovalStatus == SalesCreditLimitApprovalStatus::NotSubmitted)


return false;


custTable = this.custTable_InvoiceAccount();

if (!custTable.CreditMax)


return false;


creditBalance = custTable.CreditMax – custTable.balanceMST();

if (this.amountRemainSalesFinancial()

+ this.amountRemainSalesPhysical() < creditBalance)


return false;


return true;


8. Workflow properties on the form

  • Select the Form from AOT >> Forms on workflow will be attached
  • Set the properties related to workflow as below on form design

WorkflowEnabled = Yes

WorkflowDatasource = Table on which you added the canSubmitToWorkflow() method

WrokflowType = Workflow type created in step 4

Workflow type created

Workflow type created

9. Create workflow event handler

  • Select the Event Handler Class from AOT >> Classes to perform the action on sales order
  • Now, add the below code to change the workflow status, when the user performs action on workflow
  • Sample code

public void started(WorkflowEventArgs _workflowEventArgs)

{    select forupdate SalesTable

where SalesTable.RecId == _workflowEventArgs.parmWorkflowContext().parmRecId();



SalesTable.INDSalesCreditLimitApprovalStatus = INDSalesCreditLimitApprovalStatus::Pending;




  • Implement same code for completed and canceled method

10. Add element level event handler

  • Select the Event Handler Class from AOT >> Classes to perform the action on sales order
  • When the work flow status is updated, update the sales order enum element
  • Sample code

public void started(WorkflowElementEventArgs _workflowElementEventArgs)



select forupdate SalesTable

where SalesTable.RecId == _workflowElementEventArgs.parmWorkflowContext().parmRecId();



SalesTable.INDSalesCreditLimitApprovalStatus = INDSalesCreditLimitApprovalStatus::PendingApproval;





  • You need to perform this action on completed, change requested, canceled, created, denied and the returned method in the event handler class

11. Drag workflow approval to workflow type

  • Go to workflow node from the AOT. Select the workflow element from the workflow elements node and then after drag this element into the workflow types – >Supported elements node like the following image.
workflow types

workflow types

12. Workflow author

  • Create new display menu items. Go to AOT >> Menu Items >> Display.
  • Change the below properties in the display menu item.
    1. Set the object to WorkflowTableListPage
    2. Change the EnumTypeParameter to ModuleAxapta
    3. Set the label to Sales order credit limit workflow
    4. Set EnumParameter to Basic
Workflow author

Workflow author

  • Now drag the display menu items in the home context area page
  • Set the IsDisplayedInContentArea to Yes
  • Perform the incremental CIL

13. Create and enable workflow for sales order

  • Select the Display Menu Items which have previously been created and open it
  • Select the New button to select the workflow from the list
  • Select the Work Flow Type from the list and click on the Create Workflow
Create and enable workflow for sales order

Create and enable workflow for sales order

14. Design workflow

  • Drag and drop the approvals from Workflow Elements window to the Workflow window
  • Drag the bottom node of the Start box to the top node of Approval box
  • Drag the bottom node of the Approval box to the top node of End box
Design workflow

Design workflow

  • Now double click on the Approval box
  • Select Step from the workflow elements. Select Assignment
  • On the Assignment type tab, select User. On the User tab, select the user and drag the user into the selected user list
  • Click on the Basic Settings and then enter subject and instructions for the approval
  • Click on Save and Close
  • Enter workflow notes and click Ok
  • Then click on the Activate the New Version and click Ok

15. Now create the new sales order and check for the workflow – it will be activated in your new sales order

Ensure Efficient Workflows

Dynamics AX Workflows are important to any organization; by providing the functionality to create business processes, they define how a document flows through the system by showing the steps needed to process and approve it as well as along with who needs to process it. In Microsoft Dynamics AX, you can define workflow categories, types and elements to create custom workflows, and ensure all documents pertaining to your business are processed and approved in the most efficient manner.

Share This Post

Leave a Reply

Notify of
Skip to toolbar