Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

send the approval by using of Business Rule?

Rakhesh
Kilo Guru

Hi All,

I Have an issue., I want to send the approval by using of Business Rule. Clearly., We have a field called 'SCM'.it is choice list (Mangers). I want to send the 'SCM' to approval when the ticket status changes from 'onHold' to 'Request Approval'. 

For this scenario i wrote one BR after

I attached the all the script i wrote.Please have a look and help me where am wrong.

Thanks

Rakhesh

find_real_file.png

 

find_real_file.png

1 ACCEPTED SOLUTION

answer=[];
var app = current.u_scm;
var arr = app.split(',');
for(var i = 0; i<arr.length;i++){
var name1 = arr[i].toString();
gs.log('approver name', name1);

var getapprovar=new GlideRecord('sysapproval_approver');
getapprovar.initialize();

getapprovar.sysapproval = current.sys_id;

getapprovar.approver = name1;

getapprovar.state='requested';

getapprovar.insert();
}

I hope this will work, can you give a try. I did the testing in my instance and it worked.

 

View solution in original post

9 REPLIES 9

Harish KM
Kilo Patron
Kilo Patron

I believe your second line in query should be

getApprovar.addQuery('sysapproval', current.sys_id);

Regards
Harish

Hi thanks for reply,

 

I followed your code still no luck to me. Even the logs also not coming can you check the below code please

 

answer=[];
var app=current.u_scm;
var getapprovar=new GlideRecord('sysapproval_approver');
getapprovar.addQuery('sysapproval', current.sys_id);
gs.log("----approver inserting 1---"+sysapproval);
getapprovar.query();
while(getapprovar.next()){
answer.push(getapprovar.app.toString());
gs.log("----approver inserting 2---"+current.number);
getapprovar.update();
}

You want to create/add Users under approval table right?

i want to send the SCM to Approvals like adding the SCM Under Approval Table