Approval should go to the group manager based on the group that we are selecting on the catalog item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2024 05:46 AM
Hi ,
I'm attempting to configure the workflow's approval step. In the catalogue item, there is a field named Group [group], so after submission approval should trigger to the group manager that users had selected on the ticket.
Thanks in advance,
CD

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2024 05:56 AM
Hi @chitra1 ,
This can be done easily, please refer the KB below-
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0538552
Additional Info-
https://docs.servicenow.com/bundle/washingtondc-build-workflows/page/administer/workflow-activities/...
https://docs.servicenow.com/bundle/washingtondc-build-workflows/page/administer/workflow-activities/...
If my response has resolved your query, please consider giving it a thumbs up and marking it as the correct answer!
Thanks & Regards,
Sanjay Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2024 06:22 AM
Solution for Tokyo and Later Versions
Approval - User Activity: This is the core building block. Instead of directly assigning a group to the approval activity, you can use a script to dynamically determine the approver.
Script: In the "Approval - User" activity, use a script similar to this:
var groupName = current.variables.group; // Assuming 'group' is the variable name
var groupGR = new GlideRecord('sys_user_group');
groupGR.get('name', groupName);
if (groupGR.manager) {
answer = groupGR.manager;
} else {
// Handle the case where the group has no manager (e.g., fallback to a default user)
answer = 'fallback_user_sys_id';
}
answer Variable
* Purpose: This variable is crucial for the "Approval - User" activity. The sys_id stored in answer will be the person who receives the approval task.
fallback_user_sys_id
* Purpose: I use it as a placeholder in the script . You need to replace it with the actual sys_id of the user you want to act as the approver when a group has no manager assigned.
Workflow step would be like below –
Start --> Catalog Item Submission --> Group Manager Identification (Script) --> Approval Notification (to Manager or Fallback) --> Manager's Decision --> Approved --> Next Workflow Stage --> Rejected --> Rejection Handling (optional)
Explanation:
* Fetches Group: Retrieves the group record based on the selected group's name from the catalog item.
* Finds Manager: If the group has a manager, their sys_id is assigned as the approver.
* Fallback: If the group lacks a manager, provide a fallback mechanism (e.g., a default user's sys_id).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2024 04:47 AM
Hi @MackI ,
Thanks for your Help! I have added this script but its skipping the approval activity.
Any idea on that?
Thanks,
CD
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2024 05:19 AM
Hi @chitra1
Approval Conditions Not Met
* Check Logic: Scrutinize the conditions on your approval activity. Ensure the conditions under which the approval should trigger are actually being met in your specific scenario. Review the script carefully to ensure that it correctly calculates the due date and sets the workflow to false.
* Data Discrepancies: Double-check that the values of the relevant fields (e.g., delivery_time, due_date, any fields used in conditions) are accurate and as you expect them to be.
2. User Criteria Not Satisfied
* Approval User: Verify that the answer variable in your script is correctly identifying the intended approver's sys_id. Use background scripts or log statements to confirm the value of answer before the approval activity. Ensure that the fallback approver's user ID is valid.
* Group Manager: If you're using group-based approval, ensure the selected group has a valid manager assigned in ServiceNow.
* Approver Permissions: Make sure the approver has the necessary roles and permissions to view and act on approval tasks.
Approval Activity order
Ensure you have an approval activity order in place
Background Script
check wth background script
var gr = new GlideRecord('sc_task');
gr.get('sys_id', 'your_task_sys_id'); // Replace with actual sys_id
var intDuration = gr.cat_item.delivery_time.dateNumericValue();
gs.info("Delivery Time: " + intDuration); // Check delivery time
// ... (Rest of the due date calculation logic) ...
gs.info("Calculated Due Date: " + gdtDueDate);
gs.info("Approver: " + answer); // Check calculated due date and approver
If you like this solution. Please kindly mark this as your best answer and help to contribute more to this community