Workflow in Dynamics AX - Nasheet - DAX Helper | This blog contain development ??PPT fileWeb...
Embed Size (px)
Transcript of Workflow in Dynamics AX - Nasheet - DAX Helper | This blog contain development ??PPT fileWeb...
Workflow in Dynamics AX
Workflow in Dynamics AX 2012
Nasheet Ahmed Siddiqui
Query for a Workflow
Enable workflow on form
Workflow Providers Overview
Workflow is defined as the movement of documents or tasks through a work process.
In Microsoft Dynamics AX, the focus of workflow is on approval and task-oriented workflows.
Developer design the workflow based on customer requirements.
The company administrator configures the workflow.
Users run the workflow.
The developer role in Microsoft Dynamics AX is primarily to add workflow to existing business documents or create new documents that support workflow.
Creating a query for a workflow.
Creating a workflow category.
Creating a workflow type in the AOT.
Creating Workflow elements
Enable workflow on the form.
In the AOT, right-click the Queries node, and then select New Query. A query group displays under the Queries node.
Right-click the new query, click Rename, and then enter MyQuery.
Expand the new query, right-click the Data Sources node, and then click New Data Source. A data source group displays under the Data Sources node.
Right-click the new data source group and then click Properties.
In the Properties sheet, set the Table property to CustTable.
Expand the CusTable_1 data source, and select the Fields node. In the Properties sheet, set the Dynamic property to Yes.
Query for a Workflow
In the AOT, expand the Workflow node.
Right-click the Workflow Categories node, and then select New Workflow Category. A new workflow category group displays under the Workflow Categories node.
Right-click the new workflow category and then click Properties.
In the Properties sheet, set the name and module properties.
In the AOT, right-click MyWorkflowCategory, and then click Save.
The Workflow type is a building block that can be used to create customized workflows that enforce business policies.
In Microsoft Dynamics AX, you enable the workflow process for a workflow document by creating Workflow types that are used in the workflow configuration user interface.
A Workflow type defines information about:
Which workflow document to use.
Tasks and approvals that can be configured by the end-user.
Workflow categories used for assigning a Workflow type to a specific module.
Menu items and event handlers.
In AOT->Workflow->Workflow Types->New Workflow type.
The workflow document class that you create defines table fields for conditions in two ways:
The Application Object Tree (AOT) query. The getQueryName method of the Workflow Document Class must be overridden to return the name of the query.
Parameter methods. You can optionally add calculated fields by adding parameter methods with a specific signature on the class.
Workflow Type(Define the workflow document)
Microsoft Dynamics AX workflow uses events to initiate business logic in your application. For example, the workflow type has a property event handler for business logic when a workflow is started.
Workflow event handlers in Microsoft Dynamics AX enable you to run application-specific business logic at key points during workflow execution. Workflow events are implemented at the workflow level and the workflow element level
Event Description WorkflowStartedEventHandlerThis event raises when the workflow instance starts. WorkflowCompletedEventHandlerThis event raises when the workflow instance ends after it is completed. WorkflowCanceledEventHandlerThis event raises when the workflow instance ends after it is canceled. Use this event handler to perform any cleanup operations needed. WorkflowConfigDataChangeEventHandlerThis event raises when the workflow configuration data changes. Use this event handler to identify when a configuration has changed. For example, if you create an association between the application data and a workflow configuration, this event handler would raise if the configuration was deleted or updated.
Workflow Level Event Handlers
At the workflow level, event handlers are provided for the workflow started, completed, canceled, and configuration data change events.
WorkflowHandler class implements WorkflowCanceledEventHandler, WorkflowCompletedEventHandler, WorkflowStartedEventHandler.
Started,completed and canceled methods create to handle below events.
Create a submitWorkflow and CancelWorflow menuitems.
Set the object property of submitwork menuitem to the SubmitWorkflow class.
Set the object property of CancelWorflow menuitem to the WorkflowCancelManager class.
Workflow Menu Items
In Microsoft Dynamics AX, a workflow is started when the user clicks the Submit button on the workflow toolbar.
The Submit button is bound to an action menu item that calls the main method on a SubmitToWorkflow class.
Workflow activation is added in the main method from the workflow type name.
public static void main(Args args)
// Variable declaration.
recId _recId = args.record().RecId;
// Hardcoded type name
workflowTypeName _workflowTypeName = workFlowTypeStr("MyWorkflowType");
// Initial note is the information that users enter when they
// submit the document for workflow.
WorkflowComment _initialNote = "";
// Opens the submit to workflow dialog.
workflowSubmitDialog = WorkflowSubmitDialog::construct(args.caller().getActiveWorkflowConfiguration());
_recId = args.record().RecId;
// Get comments from the submit to workflow dialog.
_initialNote = workflowSubmitDialog.parmWorkflowComment();
// Activate the workflow.
_workflowCorrelationId = Workflow::activateFromWorkflowType(_workflowTypeName, _recId, _initialNote, NoYes::No);
// Send an Infolog message.
info("Submitted to workflow.");
info("Error on workflow activation.");
The elements of a workflow are created by you in the AOT and configured by application administrators. The workflow structure consists of sequences of workflow elements. An element can be a task, approval, or a sub-workflow.
A task is a workflow element with a single step defined in the Application Object Tree (AOT) that is used to implement task-based processes.
An approval is a specialized task that can have multiple steps defined in the AOT that is used to implement approval processes.
You can use workflow approvals to track the status of a workflow document that has fixed workflow outcome types such as Approve, Reject, Deny, or RequestChange.
AOT->WorkFlow>Approvals-> New Approval
Associate an Action Menu Item with a Workflow Approval
Associate a Display Menu item with a Workflow Approval
Create and implement event handlers on the workflow approval
Create a Workflow Approval
A workflow may contain one or more tasks. However, each task may only contain one step with one or more outcome types.
AOT->WorkFlow->Tasks-> New Task
Associate an Action Menu Item with a Workflow Task
Associate a Display Menu item with a Workflow Task
Create and implement event handlers on the workflow task
Create a Workflow Task
Property Value WorkflowEnabledYesWorkflowDataSourceCustTableWorkflowTypeCustWorkflow
Enable Workflow on Form
In the AOT, expand the Forms node.
Expand the CustTable form, and then expand the Designs node.
In the Designs node, right-click the Design child node, and then click Properties.
In the Properties sheet, set the following properties.
In the AOT, right-click the CustTable form, and then click Save.
After the form is enabled for workflow, you will add a canSubmitToWorkflow method to the form. This method runs before the Submit button is enabled to verify that the workflow document is in a valid state to submit to workflow.
Enable Workflow on Form
In Microsoft Dynamics AX, you can use workflow providers to provide application-specific information to a workflow instance at runtime.
For example, you can use workflow providers to determine who is required to approve an invoice, or by which date an invoice payment is considered to be late.
Determines a user ID based on a search in a hierarchy.
Determines the due date for a task or approval, or the due date for a step in a task or approval.