Set Approval to Requested via Business rule

Jan Janou_ek
Tera Expert

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();
}

find_real_file.png

find_real_file.png

1 ACCEPTED SOLUTION

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'.

find_real_file.png

2. Create a new flow similar to the existing one 'Change-Normal-Assess' so that new state will have approved.

 

find_real_file.png

 

 

View solution in original post

16 REPLIES 16

I have one more problem - even if I manually change all requested approvals added by BR the Approval field is still Not yet requested. I´ve tried to use the decision but the same result.

Why am I doing this - our change manager wants to check all new changes with model "Normal Large" after they are created because we never use changes here before.

Thank you.

Jan

I think what happens here, is you are trying to create Ad-hoc approvals.

Assess is the state where you do that, so the approval that is coming from the WF and the ad-hoc manager approval that you have added will be changed to requested when state changes to Asses(When you click on Request approval UI action).

And only upon approval from both entities will take the lifecycle for change further.

At least, this is how I remember implementing ad-hoc approvals for change a few years back.

 

Best Regards
Aman Kumar

Yep, looks like true. So I think there is no way to force approval in New state and prevent users to work with the Change until Change manager validates it?

You can do that, but that will require a lot changes in your ootb config, which is frowned upon.

But apart from 'New' state, what's the issue with 'Assess', that's what it stand for. To verify the change before proceeding further down the road.

 

Assess Peer review and technical approval of the change details are performed during this state.

 

Ref article:

https://docs.servicenow.com/bundle/sandiego-it-service-management/page/product/change-management/concept/c_ChangeStateModel.html

Best Regards
Aman Kumar

Thank you,  I will try to explain it to her. The idea was to prevent users work on prepare of invalid change.