- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2024 01:08 AM
Hi,
As a member of the assigned change management group of the service offering, I want to be able to cancel the Change at any stage (not closed), so that if it was raised in error, the process can continue.
I created a new UI action with condition and filter as below,
condition:
current.state != 'closed' && gs.hasRole('change_manager')
Script:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2024 01:21 AM
Hi juliet,
You can check if the user is part of the assignment group also in the ui action condition. Also you need to use the value of the state fields , here are the cancelled and closed values
So your condition becomes
current.state != '3' && gs.hasRole('change_manager') && gs.getUser().isMemberOf(''+current.assignment_group);
Make sure this is a server side ui action
Script of the ui action
current.state = '4'; // Replace 'cancelled' with the actual state value if different
gs.addInfoMessage('The change request has been cancelled.');
current.update();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2024 01:17 AM
Hi @JulietD
Your ui action script is almost seems to correct, but assignment_group on a change request might be different than the group responsible for change management. Hoope this is the point where script fails in result.
1. Condition:
current.state != 'closed' && gs.hasRole('change_manager')
Script:
(function executeCancelChange() {
var userInGroup = new GlideRecord('sys_user_grmember');
userInGroup.addQuery('group', current.assignment_group.toString()); // Convert assignment_group to string if necessary
userInGroup.addQuery('user', gs.getUserID());
userInGroup.query();
if (userInGroup.next()) {
current.setValue('state', 'Cancelled'); // Ensure ‘Cancelled’ is the correct state value in your instance
current.update();
gs.addInfoMessage('The change request has been cancelled.');
} else {
gs.addErrorMessage('You are not a member of the assigned change management group.');
}
})();
Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning
Thanks & Regards
Deepak Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2024 01:21 AM
Hi juliet,
You can check if the user is part of the assignment group also in the ui action condition. Also you need to use the value of the state fields , here are the cancelled and closed values
So your condition becomes
current.state != '3' && gs.hasRole('change_manager') && gs.getUser().isMemberOf(''+current.assignment_group);
Make sure this is a server side ui action
Script of the ui action
current.state = '4'; // Replace 'cancelled' with the actual state value if different
gs.addInfoMessage('The change request has been cancelled.');
current.update();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2024 01:47 AM
Thank you so much 😊