Logo
CAR REVIEW
Windows Vista
Windows 7
Windows Azure
Windows Server
Windows Phone
PREGNANCY
 
 
Windows Server

Workflow in Dynamics AX 2009 : Workflow Life Cycle (part 3) - Activating the Workflow

5/14/2013 5:59:05 PM
1.5 Activating the Workflow

Workflows in Dynamics AX 2009 are always explicitly activated; either a user does something in the Dynamics AX 2009 client or in Enterprise Portal that causes workflow processing to start, or the execution of business logic starts a workflow. (Once you understand how users activate a workflow, you can use this knowledge to activate workflows through business logic.)

For the first approach to activation to work, the workflow infrastructure must have a way to communicate information to the user about what to do. For example, it might be relevant to instruct the user to “Submit the purchase requisition for review and approval” at the appropriate time. The requirements to communicate with users throughout the workflow life cycle provided Microsoft an opportunity to standardize the way users interact with workflow in both the Dynamics AX 2009 client and Enterprise Portal, including activating a workflow, and this resulted in the development of workflow common controls. The workflow common controls include the yellow workflow message bar (highlighted in Figure 7) and the workflow action button, labeled Submit.

Figure 7. A purchase requisition ready to be submitted to workflow for processing

The workflow common controls appear on the purchase requisition form because it has been enabled for workflow. To enable workflow in a form, you must set the WorkflowEnabled property on the form to Yes in the Properties tab of the Design dialog box, which is shown in Figure 8. You must also set the WorkflowDataSource to one of the data sources on the form. The selected data source must be the same as the root data source that is used in the query referenced by the workflow document.

Figure 8. Design properties for a Dynamics AX 2009 form, including those for workflow


If workflow has been enabled in a form, the workflow common controls automatically appear in three cases:

  • When the currently selected document can be submitted to workflow (the canSubmitToWorkflow form method returns true).

  • When the current user is the originator of a workflow that has acted on the currently selected document.

  • When the current user has been assigned to a work item on which he or she must take an action. The workflow common control uses the algorithm shown in Figure 9 to decide which workflow configuration to use.

Figure 9. Workflow activation logic flow chart

After a workflow configuration has been identified, the workflow template is also known because there is a one-to-one relationship between a workflow configuration and a workflow template. When the workflow template is known, it’s easy for the workflow common controls to obtain the SubmitToWorkflow action menu item. This action menu item is then dynamically added to the form, together with the yellow workflow message bar.

If you look at the SubmitToWorkflow action menu item for the PurchReqApproval workflow template, you notice that it is bound to the PurchReqWorkflow class. When you click the Submit button, the action menu items call the main method on the class it is bound to; thus the code that activates the workflow is called from the main method. In this case, the call to the workflow activation API has been isolated within the submit method.

In Figure 10, notice how the Workflow::activatefromWorkflowTemplate method is used. You can use two additional APIs to activate workflows: Workflow::activatefromWorkflowConfiguration and Workflow::activateFromWorkflowSequenceNumber.

Figure 10. Submit method for the purchase requisition workflow

For information about how to use these APIs, see the Dynamics AX 2009 developer documentation on MSDN: http://msdn.microsoft.com/en-us/library/cc642844.aspx.

Understanding how to activate a workflow is important, but it is equally important to understand how to prevent a workflow from being activated. For example, you don’t want a user to submit a record to workflow before it is in a state to be submitted. An override method on forms, canSubmitToWorkflow, addresses this requirement. The canSubmitToWorkflow method returns a Boolean. True indicates that the record can be submitted to workflow. When the workflow data source on the form is initialized or when the record changes, this method is called; if it returns true, the Submit button is enabled, and if it returns false, the Submit button is disabled. Typically, you should update the state of the document after invoking the workflow activation API so that you can correctly denote when a document has or has not been submitted to workflow. (In Figure 10, the purchase requisition is transitioned to the submitted state.)

Note

If the canSubmitToWorkflow method hasn’t been overridden, the workflow common controls won’t appear on the form, leaving a reserved space at the top of the form where the controls would normally appear.

Other -----------------
- Workflow in Dynamics AX 2009 : Workflow Architecture
- SharePoint 2010 : Configuring Search Settings and the User Interface - Search Tabs and Pages
- SharePoint 2010 : Configuring Search Settings and the User Interface - Search Scopes
- SQL Server 2008 R2 : Performance Monitoring Tools (part 12) - Viewing Data Collector Set Results in Performance Monitor
- SQL Server 2008 R2 : Performance Monitoring Tools (part 11) - Creating Data Collector Sets in Performance Monitor
- SQL Server 2008 R2 : Performance Monitoring Tools (part 10) - Creating an Extended Events Session
- SQL Server 2008 R2 : Performance Monitoring Tools (part 9) - Creating an Extended Events Session
- SQL Server 2008 R2 : Performance Monitoring Tools (part 8) - Extended Events Catalog Views and DMVs
- SQL Server 2008 R2 : Performance Monitoring Tools (part 7) - SQL Server Extended Events
- SQL Server 2008 R2 : Performance Monitoring Tools (part 6) - SQL Server Utility
- SQL Server 2008 R2 : Performance Monitoring Tools (part 5) - Creating a Customized Data Collection Set
- SQL Server 2008 R2 : Performance Monitoring Tools (part 4) - Managing the Data Collector in T-SQL
- SQL Server 2008 R2 : Performance Monitoring Tools (part 3) - The System Data Collectors, Data Collector Reports
- SQL Server 2008 R2 : Performance Monitoring Tools (part 2) - Installing and Configuring the Data Collector
- SQL Server 2008 R2 : Performance Monitoring Tools (part 1)
- Microsoft Systems Management Server 2003 : Package Distribution and Management - Monitoring Status
- Microsoft Systems Management Server 2003 : Configuring the Client (part 4) - Managing the Advanced Client Download Cache, Advertised Programs Process Flow
- Microsoft Systems Management Server 2003 : Configuring the Client (part 3)
- Microsoft Systems Management Server 2003 : Configuring the Client (part 2) - Running Advertised Programs on Clients - Advertised Programs Wizard
- Microsoft Systems Management Server 2003 : Configuring the Client (part 1)
 
 
Most view of day
- Using Application Deployment Tools : Deploying Applications Using RDS (part 1) - Deploying RemoteApp Applications
- Integrating SharePoint 2013 with the Office Applications (part 6) - Microsoft Access
- Microsoft Excel 2010 : Using Formulas - Using Names To Simplify References, Inserting Formulas into Tables
- Windows Server 2003 on HP ProLiant Servers : Server Placement (part 2) - DC Placement, GC Placement
- Windows Server 2003 on HP ProLiant Servers : Security Planning and Design (part 2) - Account Lockout
- Windows Server 2012 Administration : Examining Active Directory Site Administration
- Microsoft Excel 2010 : Using Formulas - Troubleshooting Formulas
- Windows Server 2008 R2 : Creating and Administering Hyper-V Virtual Machines (part 2) - Installing the guest operating system
- Maintaining Dynamics GP : Speeding security setup with User Copy
- SQL Server 2008 R2 : Performance Monitoring Tools (part 3) - The System Data Collectors, Data Collector Reports
Top 10
- Windows Phone 8 : Scheduled Tasks - Scheduled Task API Limitations
- Windows Phone 8 : Scheduled Tasks - Updating Tiles Using a Scheduled Task Agent
- Windows Phone 8 : Scheduled Tasks - To-Do List Scheduled Task Sample (part 5) - Editing an Existing To-Do Item
- Windows Phone 8 : Scheduled Tasks - To-Do List Scheduled Task Sample (part 4) - Creating the To-Do Item Shell Tile, Saving a To-Do Item
- Windows Phone 8 : Scheduled Tasks - To-Do List Scheduled Task Sample (part 3) - Debugging Scheduled Tasks
- Windows Phone 8 : Scheduled Tasks - To-Do List Scheduled Task Sample (part 2) - TodoService, TodoItemViewModel
- Windows Phone 8 : Scheduled Tasks - To-Do List Scheduled Task Sample (part 1) - TodoItem,TodoDataContext
- Windows Phone 8 : Scheduled Tasks - Using Scheduled Tasks
- Windows Phone 8 : Scheduled Tasks - Background Agent Types
- Windows Phone 8 : Windows Phone Toolkit Animated Page Transitions - Reusing the Transition Attached Properties
 
 
Windows XP
Windows Vista
Windows 7
Windows Azure
Windows Server
Windows Phone
2015 Camaro