Workflows define how a business document flows through the system and indicates who must process and approve it. The workflow functionality in Microsoft Dynamics AX 2012 helps ensure that documents are processed and approved in a consistent and efficient manner. Read on to understand the workflow system in Microsoft Dynamics AX and see how you can configure, extend, and use it.
Custom Workflows in Dynamics AX 2012
Below mentioned are elements integral to the custom workflow functionality in Dynamics AX:
Workflow category
When you create a workflow type in Microsoft Dynamics AX, it must be assigned to a workflow category. The workflow category indicates if a particular workflow type is available in a specific module. If an appropriate workflow category does not already exist, you must create one.
Workflow query
You can create a query to retrieve data by using the query classes.
Workflow type
To add workflow support for a document in Microsoft Dynamics AX, you must create a workflow type. The workflow type can then be used to create workflow configurations. Workflow types should be created to define:
Workflow documents
Workflow categories
Tasks and approvals for the workflow
Event handlers such as workflow started, completed, configuration data change, and cancelled
A SubmitToWorkflowMenuItem
Workflow elements
Any workflow 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 table: To maintain the workflow status as per the table record
canSubmitToWorkflow() method to table: To check if a record should be submitted to the workflow or not
Workflow properties on form: To set created workflow elements on workflow property of the related form
Display menu items: To create new workflows on the list page
Form: To perform workflow activities on the form
Creating Custom Workflows
Below is the process to create a custom workflow for a sales module where a sales order will be submitted for approval, if the credit limit for the customer related to the sales order is exceeded.
Below is the process to create a custom workflow for a sales module where a sales order will be submitted for approval, if the credit limit for the customer related to the sales order is exceeded.
1. First of all, make sure that batch jobs that handle workflow execution are running.
If batch jobs are not running, they can be started from System Administrator >> Setup >> Workflow >> Workflow infrastructure configuration.
Follow the workflow infrastructure wizard and set batch groups for all process.
2. Create workflow category
Expand Workflow Categories node in AOT >> Workflow.
Create New Workflow Category
Set name, label, and module properties for newly created workflow category
3. Create query
Expand the Queries node in AOT
Click on New Query
Set properties like Title and Description on the newly created query
Expand the newly created query
Add main data source
Set dynamic property of field node of added data source to Yes
4. Create workflow type
Expand Workflow Type node in AOT >> Workflow
Create New Workflow Type using workflow type wizard
Follow the wizard and set workflow type name, category (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 a list of objects that are going to be created. A new development project with new elements will be created
5. Create Base Enum
Expand 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)
6. New field in table
Select table (on which the workflow will work) from AOT >> Data Dictionary >> Tables
Add new enum type field and set enum type property to enum created in previous step
Compile and synchronize the table
7. canSubmitToWorkflow() method to table
Expand method node on table (on which the workflow will work)
Add/modify the canSubmitToWorklfow() method to check whether record should be added to the workflow or not. This method contains code which defines eligibility of record to submit it to workflow
You need to perform this action on completed, change requested, canceled, created, denied and returned method in the event handler class
11. Drag workflow approval to workflow type
Go to workflow node from the AOT. Select workflow element from the workflow elements node and then after drag this element into the workflow types - >Supported elements node like the following image
12. Workflow author
Create new display menu items. Go to AOT >> Menu Items >> Display.
Change the following properties in the display menu item.
Set the label to "Sales order credit limit work flow"
Set the object to WorkflowTableListPage
Set the EnumTypeParameter to ModuleAxapta
Set the EnumParameter to Basic
Now drag 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 Display Menu Items which have previously been created and open it
Select New button to select workflow from the list
Select the Work Flow Type from the list and click on Create Workflow
14. Design workflow
Drag and drop the approvals from the Workflow Elements window to the Workflow window
Drag the bottom node of the Start box to the top node of the Approval box
Drag the bottom node of the Approval box to the top node of the End box
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 user into the selected user list
Click on 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 Activate the New Version and click Ok
15. Now create a new sales order and check for the workflow – it will be activated in your new sales order
Ensure Efficient Workflows
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 along with who needs to process it. In 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.
Angna Thakkar is a competent Senior Project Manager, Microsoft Dynamics AX Technical at Indusa with over 10 years of experience in managing multi-disciplinary teams of varying sizes and complex programs of work. She is always committed to professionalism, highly organized, able to see the big picture while paying attention to small details.
3 thoughts on “Creating Custom Workflows in Dynamics AX 2012”
Ahmed
First thanks,
Second
In step 2: You've created enum with name INDSalesCreditLimitApprovalStatus and only for status (NotSubmitted/Submitted/Approved/Rejected)
In Step 7: You've used Enum with name (SalesCreditLimitApprovalStatus) which is not created!
In Step 9: You've used INDSalesCreditLimitApprovalStatus::Pending but (Pending) is not an element of this enum!
In Step 10: You've used INDSalesCreditLimitApprovalStatus::PendingApproval and also (PendingApproval) is not an element of this enum!
Also A note in step 10 says You need to perform this action on completed, change requested, canceled, created, denied and returned method in the event handler class but what is the correct status for those methods?
PS: _workflowElementEventArgs cannot be used in the created method so how to use it?
Getting integrated with the right work-flow is of utmost importance for any ERP software to make sure that the tasks are getting complete in right flow and in right manner for optimum productivity.
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies. However you may visit Cookie Settings to provide a controlled consent.
This website uses cookies to improve your experience while you navigate through the website. Out of these cookies, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may have an effect on your browsing experience.
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
First thanks,
Second
In step 2: You've created enum with name INDSalesCreditLimitApprovalStatus and only for status (NotSubmitted/Submitted/Approved/Rejected)
In Step 7: You've used Enum with name (SalesCreditLimitApprovalStatus) which is not created!
In Step 9: You've used INDSalesCreditLimitApprovalStatus::Pending but (Pending) is not an element of this enum!
In Step 10: You've used INDSalesCreditLimitApprovalStatus::PendingApproval and also (PendingApproval) is not an element of this enum!
Also A note in step 10 says You need to perform this action on completed, change requested, canceled, created, denied and returned method in the event handler class but what is the correct status for those methods?
PS: _workflowElementEventArgs cannot be used in the created method so how to use it?
Helped a lot!
Thank you
Getting integrated with the right work-flow is of utmost importance for any ERP software to make sure that the tasks are getting complete in right flow and in right manner for optimum productivity.