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.

Business Rule to update reference fields on table

jackinsidend
Giga Guru

I have a custom table, that has a reference field to a RITM number in it.

I also have a requested_by reference field in that table.

When someone changes the RITM number in my custom table, I would like it to update the requested_by field in my custom table to match the requested_by value for that RITM in the sc_req_item.

This seems like it should be simple, but I cannot get it to work...

Ideas?

1 ACCEPTED SOLUTION

jackinsidend
Giga Guru

I could not get to it this way, my business rule was good, but I was looking for the wrong value. I was thinking we had requested_by instead of requested for..

Simple enough in end, once I had the right field...

 

(function executeRule(current, previous /*null when async*/) {
// gs.addInfoMessage(current.u_ritm);
var getReqby = new GlideRecord('sc_req_item');
getReqby.addQuery('sys_id', current.u_ritm);
getReqby.query();
if(getReqby.next()){
current.u_requested_by = getReqby.request.requested_for;
current.u_uses_netid_s =getReqby.variables.netid_passwords;




}
})(current, previous);

 

View solution in original post

2 REPLIES 2

SanjivMeher
Mega Patron
Mega Patron

You need an update onBefore business rule for this with 

 

Condition

RITM Number Changes

 

Action->

Set Value

Requested By 'Same as' Requested Item.Request.Requested For


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

jackinsidend
Giga Guru

I could not get to it this way, my business rule was good, but I was looking for the wrong value. I was thinking we had requested_by instead of requested for..

Simple enough in end, once I had the right field...

 

(function executeRule(current, previous /*null when async*/) {
// gs.addInfoMessage(current.u_ritm);
var getReqby = new GlideRecord('sc_req_item');
getReqby.addQuery('sys_id', current.u_ritm);
getReqby.query();
if(getReqby.next()){
current.u_requested_by = getReqby.request.requested_for;
current.u_uses_netid_s =getReqby.variables.netid_passwords;




}
})(current, previous);