Dynamics ax 2012 workflow development

4,234 views

Published on

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
4,234
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
318
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Dynamics ax 2012 workflow development

  1. 1. Dynamics AX 2012 - Workflow Development in 2 hrsHi Friends,First of all would like to wish you all Very "Happy and Dynamics new year-2012".You all might be aware/heard of new changes related to worklow architecture and development.So this post basically addresses,1. Workflow Architecture changes2. Workflow Development wizards3. Generic class for submit/resubmit events on all workflows in AX.1. Workflow Architecture changesIn 2012, AOS service has gone tremendous changes like- Now you can directly host WCF services on AOS.- Earlier version we were using IIS to interact with WWF(Windows workflow foundation) and WCF (Windows communication foundation).- Because of above change, now no need to install workflow component separately- Just run the workflow configuration wizard (available in System administration->Setup)- Workflow templates/configuration were made available across companies/per company level.- Workflow template is renamed to Workflow types2. Workflow Development through wizards.Let us develop workflow for Customer approval- New created customer should be approved through workflowStep 1: Create a query for custTable say CustApprWorkflowQry in AOT->QueriesStep 2: Duplicate enum PurchReqWorkflowState and rename it to CustApprWorkflowState and drag itto CustTable Table.Step 3: Override canSubmitToWorkflow method on Table->CustTable and paste below code. //BP Deviation Documented public booleancanSubmitToWorkflow(str _workflowType = ) { boolean ret; ret = this.RecId != 0 &&this.CustApprWorkflowState == CustApprWorkflowState::NotSubmitted; return ret; }Create new method on CustTable as below to update worklow state during its life cycle.
  2. 2. //BP Deviation documented public static void UpdateCustWorkflowState(RefRecId _recId, CustApprWorkflowState_state) { CustTablecustTable = CustTable::findRecId(_recId, true); ttsBegin; custTable.CustApprWorkflowState = _state; custTable.update(); ttsCommit; }Step 4: Create workflow type (template/configuration) through wizard available in 2012. Run wizard as below: AOT->Workflow-> Workflow types (Right click ->Add-Ins-> workflow type wizard... Specify values as shown in below image Click on next, as shown in below image wizard will create workflow eventhandlers class and menuitems for you. Paste below code to update workflow state.
  3. 3. //BP Deviation Documented public void started(WorkflowEventArgs _workflowEventArgs) {CustTable::UpdateCustWorkflowState(_workflowEventArgs.parmWorkflowContext().parmRecId(), CustApprWorkflowState::Submitted); } //BP Deviation Documented public void completed(WorkflowEventArgs _workflowEventArgs) { CustTable::UpdateCustWorkflowState(_workflowEventArgs.parmWorkflowContext().parmRecId(), CustApprWorkflowState::Completed); } //BP Deviation Documented public void canceled(WorkflowEventArgs _workflowEventArgs) {CustTable::UpdateCustWorkflowState(_workflowEventArgs.parmWorkflowContext().parmRecId(),CustApprWorkflowState::PendingCancellation); }Step 5: Create workflow approval through wizard available in 2012. Run wizard as below: AOT->Workflow->Approvals (Right click ->Add-Ins-> Approval wizard... Specify values as shown in below image Click on next, as shown in below image wizard will create workflow element eventhandlers and menuitems for you.
  4. 4. Paste below code to update workflow state. //BP Deviation Documented public void started(WorkflowElementEventArgs _workflowElementEventArgs) { CustTable::UpdateCustWorkflowState(_workflowElementEventArgs.parmWorkflowContext().parmRecId(), CustApprWorkflowState::Submitted); } //BP Deviation Documented public void returned(WorkflowElementEventArgs _workflowElementEventArgs) { CustTable::UpdateCustWorkflowState(_workflowElementEventArgs.parmWorkflowContext().parmRecId(), CustApprWorkflowState::Returned); } //BP Deviation Documented public void changeRequested(WorkflowElementEventArgs _workflowElementEventArgs) {CustTable::UpdateCustWorkflowState(_workflowElementEventArgs.parmWorkflowContext().parmRecId(), CustApprWorkflowState::ChangeRequest); } //BP Deviation Documented public void completed(WorkflowElementEventArgs _workflowElementEventArgs) {CustTable::UpdateCustWorkflowState(_workflowElementEventArgs.parmWorkflowContext().parmRecId(), CustApprWorkflowState::Approved); } //BP Deviation Documented public void canceled(WorkflowElementEventArgs _workflowElementEventArgs) { CustTable::UpdateCustWorkflowState(_workflowElementEventArgs.parmWorkflowContext().parmRecId(), CustApprWorkflowState::PendingCancellation); }Step 6: Enable workflow on CustTableListPage form and alos drag field CustApprWorkflowstate on
  5. 5. form overview grid, as below CustTableListPage->Design, set properties as belowStep 7: Download below class to activate workflow on submit and resubmit. This is generic class and with little modification can be used for all different worklows in AX. Download Class XPO : Once you download and import class, change below menu-items associated with submit andresubmit actions.Step 8: Run Incremental CIL generation, AOT->Right click-> Incremental CIL generationYou are done with development and can configure workflow in AR->SetupAfter activating above workflow configuration test it by creating new customer in CustTableListPageform.Hope you enjoyed this new style of workflow development which will take 1-2 hours for any newbasic workflow approval :)

×