In servicenow, we triggered the approval from flow designer to only one group. But now the requirement is that, i want to trigger the approval based on assignment group of particular task. For example., In ritm if delhi assignment group is populated through assignment rule then the approval gone to only specific member of that group and if no group is populated then approval gone to IT desk group.
Assistant
User
My requirement is when previous task closed and assignment group is delhi then approval goes to the particular person of the group selected in previous closed task.. we have 25 groups of this type. Give me best way to do this
Assistant
To achieve this requirement in ServiceNow using Flow Designer, you will need to create a flow that has conditions and actions to handle the approvals based on the assignment group. Here's a step-by-step approach to achieve this:
Create or Modify Flow: First, ensure you have a flow in Flow Designer that is designed to handle the approvals for your RITM (Request Item).
Trigger Configuration:
Make sure the flow is triggered correctly. Typically this would be on RITM creation or update when a specific condition is met.
Add Condition to Check Assignment Group:
You need to add a condition that checks if the assignment_group field is populated.
Also, within the same condition, you might need an additional sub-condition to check if the specific assignment group (like "Delhi") is populated.
Create Approval Actions:
On the path where assignment_group is populated and matches the specific group (like "Delhi"), create an approval action that assigns the approval to a specific member of the group.
On the path where no assignment_group is populated, create another approval action that assigns the approval to the default group (like "IT Desk").
Detailed Steps
Open Flow Designer:
Navigate to Flow Designer (Self-Service > Flow Designer).
Create a New Flow or Edit Existing Flow:
Click on "New" to create a new flow, or select an existing flow to edit.
Add Trigger:
Add a trigger for the flow, for example, "When an RITM is created or updated."
Add Condition to Check Assignment Group:
Drag a "If" condition onto the canvas.
Create a condition to check if assignment_group is populated.
plaintext
If Current Record > Assignment Group > is not > Empty
Add Sub-Condition for Specific Group:
Drag another "If" condition within the previous one.
Check if the assignment_group is "Delhi" (or the specific group criteria).
plaintext
If Current Record > Assignment Group > is > Delhi (or the desired group name/ID)
Approval Action for Specific Member:
Add an "Approval" action on the true path of the sub-condition.
Configure the approval to be assigned to the specific member.
plaintext
Approval for specific member:
- Approval type: Users
- Users: Select the specific member
Approval Action for Default Group:
On the false path of the first "If" condition (where the assignment group is not populated), add another "Approval" action.
Configure the approval to be assigned to the default group (like "IT Desk").
plaintext
Approval for IT Desk:
- Approval type: Groups
- Groups: IT Desk Group
Save and Test the Flow:
Save the flow and test it by creating or updating RITMs with different assignment groups.
Ensure the approvals are routed correctly based on the assignment group settings.
By following these steps, you can dynamically assign approvals based on the assignment_group of the RITM, ensuring that the correct individuals or groups receive the approval tasks as per your requirements.
To achieve this requirement in ServiceNow using Flow Designer, you'll need to create a flow that triggers when a task (e.g., a previous task) is closed. This flow will then check the assignment group of the closed task and determine the appropriate approval recipient for the new task.
Here's a step-by-step approach to achieve this:
Step 1: Create or Modify Flow
Open Flow Designer:
Navigate to Flow Designer (Self-Service > Flow Designer).
Create a New Flow:
Click on New to create a new flow, give it a name like Dynamic Approval based on Previous Task.
Step 2: Define Trigger
Add Trigger:
Set the trigger to be when a task is closed. Typically, you may use Record Update to trigger when a specific field (like the task state) is updated to closed.
Configure it for your specific table (e.g., Task, Incident, or a custom table).
Step 3: Add Conditions and Variables
Add Condition:
Add an If condition to check if the task is closed.
plaintext
If [Trigger Record > State] is [Closed]
Get Assignment Group and Member:
Use a Lookup Record or Script Step to get the Assignment Group and the specific member who should receive the approval.
You will fetch the assignment group's specific member, which was part of the previous task.
Step 4: Add Approval Action
Add Approval Action:
Add an Approval action based on the result from the Lookup or Script step.
Configure this approval to assign to the user fetched from the previous task.
Detailed Implementation
Using Script Step to Retrieve Assigned User
Script to Fetch Assigned User:
Add a Script Step to your flow to retrieve the user from the previous assignment group. Here's an example script:
javascript
(function() {
var taskGR = new GlideRecord('task');
taskGR.get(gs.action.getGlideURI().get('sys_id').toString());
if (taskGR.assignment_group) {
var assignedTo = ... // write logic to fetch specific user based on group
// you can fetch user details from group, or search users who were in this group
}
return {
'assignedTo': assignedTo
};
})();
Passing Script Results to Approval:
Ensure to return the assignedTo value which would be used in the Approval action.
This returned value can be used in the next steps of the flow.
Approval Configuration:
Add the Approval action:
plaintext
Approval type: User
Users: assignedTo (use the output from the script step)
Creating Dynamic Approvals
For 25 groups, ensure the logic in your script is comprehensive enough to dynamically fetch the user. This could be optimized with a mapping if the specific user in the group is predefined.
Example Flow Summary
Trigger:
Record Update on Task Table when State is Closed.
Condition:
If task is closed:
Script Step: Fetch assigned user from the assignment group.
Approval Action: Assign approval to the fetched user.
Saving and Testing
Save the flow, then test it by closing a task and ensuring the approval assignment logic functions correctly.
Additional Suggestions
To make the solution robust:
Consider error handling in the script if no user is found.
Log actions for traceability.
Use ServiceNow data lookup functionality if possible for maintainability.
By structuring your flow and logic in this manner, you can dynamically route approvals based on the previous task's assignment group.