Sei sulla pagina 1di 23

By, Nasheet Ahmed Siddiqui

Agenda
Workflow overview Workflow development
Query for a Workflow Workflow category Workflow type Workflow elements Enable workflow on form Workflow Providers Overview

Workflow configuration

Workflow 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.

Workflow overview

Developer design the workflow based on customer requirements. The company administrator configures the workflow. Users run the workflow.

Workflow development
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.

Query for a Workflow


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.

Workflow Category
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:

Workflow Type

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.

Workflow Type
In AOT->Workflow->Workflow Types->New Workflow type.

Workflow Type(Define the workflow document)

The workflow document class that you create defines table fields for conditions in two ways:
1. The Application Object Tree (AOT) query. The getQueryName method of the Workflow Document Class must be overridden to return the name of the query. 2. Parameter methods. You can optionally add calculated fields by adding parameter methods with a specific signature on the class.

Workflow Events

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

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.
Event Description WorkflowStartedEventHan This event raises when the workflow instance starts. dler WorkflowCompletedEvent Handler WorkflowCanceledEventH andler This event raises when the workflow instance ends after it is completed. This event raises when the workflow instance ends after it is canceled. Use this event handler to perform any cleanup operations needed. This 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

WorkflowConfigDataChan geEventHandler

Workflow Menu Items


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.

SubmitToWorkflow Class
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.

SubmitToWorkflow Class
} public static void main(Args args) { // Variable declaration. recId _recId = args.record().RecId; WorkflowCorrelationId _workflowCorrelationId; // Hardcoded type name workflowTypeName _workflowTypeName = workFlowTypeStr("MyWorkflowType"); // Initial note is the information that users enter when they // submit the document for workflow. WorkflowComment _initialNote = ""; WorkflowSubmitDialog workflowSubmitDialog; // Opens the submit to workflow dialog. workflowSubmitDialog = WorkflowSubmitDialog::construct(args.caller().getActiveWorkflowConfiguration()); workflowSubmitDialog.run(); if (workflowSubmitDialog.parmIsClosedOK()) { _recId = args.record().RecId; // Get comments from the submit to workflow dialog. _initialNote = workflowSubmitDialog.parmWorkflowComment(); try { ttsbegin; // Activate the workflow. _workflowCorrelationId = Workflow::activateFromWorkflowType(_workflowTypeName, _recId, _initialNote, NoYes::No); // Send an Infolog message. info("Submitted to workflow."); ttscommit;

catch(exception::Error) { info("Error on workflow activation."); }

Workflow elements
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 subworkflow. 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.

Create a Workflow Approval

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 Task


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

1.In the AOT, expand the Forms node. 2.Expand the CustTable form, and then expand the Designs node. 3.In the Designs node, right-click the Design child node, and then click Properties. 4.In the Properties sheet, set the following properties. Property
WorkflowEnabled WorkflowDataSource WorkflowType

Enable Workflow on Form


Value
Yes CustTable CustWorkflow

5.In the AOT, right-click the CustTable form, and then click Save.

Enable Workflow on Form


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.

Workflow Providers
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.

Workflow Providers Types

Hierarchy Assignment
Determines a user ID based on a search in a hierarchy.

Due date
Determines the due date for a task or approval, or the due date for a step in a task or approval.

Participant
Resolves a user group or role into one or more specific user IDs.

Demo

Potrebbero piacerti anche