CMDB CI Request approval
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2024 12:41 AM
Hi all,
I have a requirement in change , based upon the selection of CMDB CI group Request needs to go to Particular CI Approval group
How can i achieve this
Approver group is change_approver
how can i sent request to the particular group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2024 07:33 AM
Hey @MK21
- Workflow Script (Recommended):
- Create a workflow that runs on the "change.after" insert or update event.
- Within the workflow script:
- Access the selected CMDB CI group using current.cmdb_ci.getRecord().
- Use a conditional statement to determine the appropriate approval group based on the CMDB CI group.
- Set the change_approver field of the change record to the corresponding approval group sys_id using current.change_approver = approval_group_sys_id.
- Update the change record using current.update().
// Get the selected CMDB CI record
var cmdbCiRecord = current.cmdb_ci.getRecord();
// Define mapping logic for CMDB CI group to approval group (replace with your specific mapping)
var approvalGroupMap = {
'Network Device Group': 'NET_APPROVAL_GROUP', // Replace with actual sys_id
'Server Group': 'SERVER_APPROVAL_GROUP' // Replace with actual sys_id
};
// Get the approval group based on the CMDB CI group
var approvalGroup = approvalGroupMap[cmdbCiRecord.getDisplayValue('group')];
if (approvalGroup) {
current.change_approver = approvalGroup;
current.update();
} else {
// Handle cases where there's no mapping for the selected CMDB CI group
gs.warning("No approval group mapping found for CMDB CI group: " + cmdbCiRecord.getDisplayValue('group'));
}
Explanation:
- The script retrieves the CMDB CI record associated with the change request.
- It defines a mapping object (approvalGroupMap) to link CMDB CI groups with their corresponding approval groups (replace with your specific structure).
- It retrieves the approval group sys_id based on the CMDB CI group's display value.
- If a matching approval group is found, it sets the change_approver field on the change record and updates the record.
- A warning message is logged if no mapping is found for the selected CMDB CI group.
Business Rule (Alternative):
- Create a business rule that runs on the "change.before" insert or update event.
- Use a similar conditional statement to determine the approval group based on the CMDB CI group from the current.cmdb_ci field.
- Set the change_approver field to the corresponding approval group sys_id using current.setValue('change_approver', approval_group_sys_id).
Benefits of Workflow Script:
- The workflow script approach allows for more flexibility and control over the approval group assignment process. You can execute additional logic or error handling within the script as needed.
Choosing the Right Method:
- If you need more granular control over the approval group assignment logic or require additional actions during the assignment process, the workflow script is generally preferred.
- If you have a simpler mapping and want a more declarative approach, the business rule could be sufficient.
Additional Considerations:
- Ensure the workflow or business rule has the necessary read access on the cmdb_ci and sys_user_group (or your approval group table) tables.
- Test your implementation thoroughly to verify that the approval group is assigned correctly based on the selected CMDB CI group.
By implementing one of these approaches, you can dynamically assign the change request approval group based on the CMDB CI group selection, streamlining your change approval workflow in ServiceNow.
Thanks
Aravind Panchanathan