- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2022 04:43 AM
Hello folks!
I would like to ask you for help with this - I need to create approval from members of Change Manager group when anybody creates a new Change with model "Normal large" and set Approval to "Requested".
I found the script below and I am able to generate approval task to both member of that group from Business rule on the "Change_request" table. But I can´t to use "Approval" field in UI Policy condition because it is still "Not yet requested". Is there any way how to change it also?
Thx!
Jan
(function executeRule(current, previous /*null when async*/) {
var appgroup = "87950d301b084910d73065fde54bcbd9";
var getapprovers=new GlideRecord('sys_user_grmember');
getapprovers.addQuery('group',appgroup);
gs.log('approver grp', appgroup);
getapprovers.query();
while(getapprovers.next())
{
gs.log('approver name',getapprovers.toString());
var gr=new GlideRecord('sysapproval_approver');
gr.initialize();
gr.sysapproval = current.sys_id;
gr.approver = getapprovers.user.sys_id.toString();
gr.state='requested';
gr.insert();
}
Solved! Go to Solution.
- Labels:
-
Script Debugger
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2022 03:10 AM
Thanks. You may follow the below steps to achieve your requirement. I have checked that approves are getting added and once they approve, the change approval status is updated to 'approved'.
Having said that, please explain to the customer the OOTB behaviour and see if you can proceed with that.
1. Create a new decision of 'Normal Change Policy'. Refer to 'New Approval'.
2. Create a new flow similar to the existing one 'Change-Normal-Assess' so that new state will have approved.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2022 04:56 AM
Hi Jan,
The approval field on the change record is simply a string so you can simply include setting that value somewhere in your business rule. Just remember that if you rule is after update, you'll need to save that change record again.
Hope that helps.
:{)
Helpful and Correct tags are appreciated and help others to find information faster
:{)
Helpful and Correct tags are appreciated and help others to find information faster
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2022 05:57 AM
Hello John,
but how can I change value for "Approval" in the first image? BR will be only after insert a new change.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2022 07:49 AM
I ran the same code in my instance, its working as expected and states are being set to "Requested".
Can you check if you have BR that might be restricting your state transition to "Requested"?
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2022 12:27 PM
Hi Aman,
yep, it works on the change form but I also need to set "Approval" on the list of all Changes as you can see on this screen or the link - nav_to.do?uri=%2Fchange_request_list.do%3Fsysparm_userpref_module%3D3f1711211b6c0990d0315205604bcbab%26sysparm_query%3Dactive%253Dtrue%255EEQ%26sysparm_clear_stack%3Dtrue