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

Feel free to Mark correct, if this finally goes through 🙂

Best Regards
Aman Kumar

The goal here is to meddle as less as we can with already complex oob workflow, ans what your requirement states, OOB config stands correct for that.

Best Regards
Aman Kumar

Viknesh Pannirs
Tera Expert

The BR should execute before record creation to set any field value. In this case, the value 'Approval' can be set to 'Requested' if you could write the BR before the record create update.

find_real_file.png

 

find_real_file.png

Yep, this works and Approval is requested but there are still no approvers and when I add them via the business rule the Approval doesnt change after their approve. Maybe I can try to change it via another BR.

Thanks.

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