Business Requirement:
Customer has a requirement to trigger different workflows based on a field change during the first workflow approval process.
Customer has a MDF portlet for an Expense Claim Request where an employee can raise the request as part of ESS. When the employee submits the request, the workflow should be triggered to Manager, Division Head or Department Head and Finance. But while manager approves the workflow, he has to select whether the cost is accounted towards Department Level or Division level. When he chooses Department level, then Department head has to be included in the workflow or if he chooses Division level, then the Division head has to be included in the workflow.
To achieve this, we need to use the “Edit with Route Change” option in the workflow along with Login User method in the business rule.
Also, business wanted to validate Cost Allocation field which should not be blank when manager approves the request. This is also a limitation where we will be able to validate the fields only on the last step if the workflow has multiple steps. For this limitation, this concept can be a workaround by splitting the workflows. For example, if you have a three-step workflow and if you need to validate a field on step 1, then split the workflow in two workflows with the first workflow with “Edit with Route Change” and trigger the second workflow using the business rule with conditions built accordingly.
Configuration Steps:
- Create three workflows as like below.
Workflow 1: Step 1 – Manager, Edit with Route Change
Workflow 2: Step 1 – DivisionHead, No Edit; Step 2 – Finance, No Edit
Workflow 3: Step 1 – Department Head, No Edit; Step 2 – Finance, No Edit
- Create the Object with required fields with Pending Data option to Yes .
- Create UI with field Cost Allocation removed as only the manager should select this field and assign it on People Profile.
- Create a business rule to trigger the workflow and assign it onSave section. The logic for the business rule: When the employee submits the request, we need to trigger the first workflow and when manager changes the value and approves the request, because of the route change, the WF rule will trigger again. Now we need to have the conditions built to check if the login user is manager, then set the workflows accordingly based on the field value.Workflow Rule:
Validation business rule:
Assign the rules:
Testing the Functionality:
Employee Raising Request:
Triggers the workflow with one step(Manager):
When Manager tries to Approve with blank Cost Allocation, error message has been shown:
When Manager selects “Division” as the cost allocation on the workflow and approve, then the second workflow triggers:
When Manager selects “Department” as the cost allocation on the workflow and approve, then the third workflow triggers:
Note: Using Edit with route change option, the first workflow will be cancelled and new workflow will be triggered, but in the activity section you will see all actions happened.