Tuesday, 9 October 2018

Add hierarchy token in WorkflowLimitHierarchyProvider for custom workflow in AX 2012

Hierarchy assignment provider is used to determine a user Id based on a search in a hierarchy. As we all know that hierarchy provider gives limited options for the starting point of the workflow hierarchy and those options are :

  • Workflow originator : It is the user who is submitting the workflow. 
  • Workflow owner : It is the user who is configuring the workflow.
  • WorkerRecId
  • Personnel Number
Let's say we have scenario in which a person is making a request on behalf of any employee and we need to send  that request to level 1 manager or  immediate supervisor of employee for approval. In this case we won't be able to find out any starting through standard hierarchy start points. For achieving our goal we have potentially two methods :
  1. We can make changes in standard WorkflowLimitHierarchyProvider class. Since it is available for all workflow types and its association type is set on global level.
  2. Create a new hierarchy assignment provider and hierarchy provider class. This class will implement workflowHierarchyProvider interface and we will attach it will our custom hierarchy assignment  provider. 
Note : Right now I am following  first approach but it is not recommended because we might face issue in future upgrade.

Following  are the steps required to make those changes.

Step 1) Go to AOT ->Workflow node -> Providers -> Hierarchy Assignment -> WorkflowLimitHierarchyProvider. Right click on it and check its properties. Here you will find out the provider class  in which you need to do customization for your custom workflow.










Step 2) Create a new custom EDT which will extend HcmWorkerRecId.













Step 3) Assign this newly created EDT to your employee id field on custom table.

Step 4) Go to AOT -> Classes -> WorkflowLimitHierarchyProvider 

Here you need to make changes in following methods.
  • GetSupportedDataType : In this method we will add code our newly created EDT.
  • convertToNodeDataType : Here on basis of newly created EDT we will be able to get our worker/ employee recid  who request is to be submitted to its manager. After getting the worker recid we will find out its personnel number.
Note: I am not using standard EDT of HcmWorkerRecId directly because it will be used by many tables.



















Step 5) Go to your workflow configuration-> Approval -> Step -> Assignment -> Hierarchy Selection. Now verify your custom start point  and drop down will be showing  worker token. I have added expression of employee level 1. So the workflow will be submitted to employee immediate manager or super visor for approval.




















You may verify your employee immediate super visor by following this navigation : Human Resources -> Worker position assignment -> Click on position -> New form will opened of position -> View in hierarchy . Here IT Head immediate supervisor is Mohsin Akram.







Also check hierarchy relationship and record should add for the assignment of  reports to position (Mohsin Akram).






No comments:

Post a Comment

Note: only a member of this blog may post a comment.

Custom Business events Part 3 - (Activate custom business event) in D365 F&O

 In this blog we will discuss about the steps to activate a custom business in D365 F&O. As we know that business event catalog does not...