Update sysapproval_approver table with a field from change_request

brown9394
Tera Expert

Hello, 

I have a requirement to update a field on a sysapproval_approver table with a field from change_request table - anytime this changes. I'm trying to do this by using a BR on change_request to run after / update but no luck so far. 

Condition: current.close_code.changes()

Script: 

(function executeRule(current, previous /*null when async*/) {


var chg = new GlideRecord('sysapproval_approver');
chg.addQuery('sys_id', current.sys_id);
chg.query();

if(chg.next()) {
chg.u_close_code = current.close_code;
chg.update();
}

})(current, previous);

Any help would be great! 

Thanks! 

1 ACCEPTED SOLUTION

Use below script.

 

(function executeRule(current, previous /*null when async*/) {


var chg = new GlideRecord('sysapproval_approver');
chg.addQuery('sysapproval', current.sys_id);

chg.addQuery('state', 'requested');
chg.query();

while(chg.next()) {
chg.u_close_code = current.close_code;
chg.update();
}

})(current, previous);


Please mark this response as correct or helpful if it assisted you with your question.

View solution in original post

5 REPLIES 5

Hello @SanjivMeher , i need similar fucntionality but with a particular approver, trying to query with approver as well but of no luck .could you please provide some solution .Any help is appreciated.Thanks!

eg.,   groupGR1.addQuery('approver', groupMember1.manager);