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.

How to dot walk in Business rule

shaik_irfan
Tera Guru

Hello Everyone,

I want to populate a field name which is present on u_bsa table.

On u_bsa table i field named as Req for which was dot walk by sc_req_item table, i want to display that Req for field name for which i written a script like below

i am getting a display value as undefined

var ritm = new GlideRecord('u_bsa');

if(ritm.get(current.sysapproval)){

var req_for = ritm.u_requested_for.name;   //Output i am getting is undefined

var ge = ritm.u_requested_item.number; // I am getting correct output here

gs.addInfoMessage(req_for);

gs.addInfoMessage(ge);

1 ACCEPTED SOLUTION

Try



var req_for = ritm.u_requested_item.u_requested_for.getDisplayValue()



Manish


View solution in original post

16 REPLIES 16

Thank you. Your description said you were looking to dot-walk in a business rule.



Which table does the notification use (to better understand what current refers to)?




Am I correct in assuming that u_requested_for is a reference field to sys_user and u_requested_item is a reference to sc_req_item?


Sorry it was a TYPO



Notification uses Approval table



Yes your assumption is correct,



u_requested_for is a reference field in RITM table which is referring to user table & u_requested_item is a reference to sc_req_item.



I dot walk using form layout and populated Requested for name in u_bsa from RITM table.



find_real_file.png




I know it's not going to matter much, but have you tried this instead:



(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,


              /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,


              /* Optional GlideRecord */ event) {


                // Add your code here


        var ritm = new GlideRecord('u_bsa');


        gs.addInfoMessage('current.sysapproval=' + current.getValue('sysapproval'));


        if (ritm.get(current.getValue('sysapproval'))) {


                  var req_for = ritm.u_requested_for.getDisplayValue();


                  var ge = ritm.u_requested_item.getDisplayValue();


                  gs.addInfoMessage(req_for);


                  gs.addInfoMessage(ge);


                  template.print("" + ritm.u_requested_for.getDisplayValue());


                  //template.print(req_for);


        }


})(current, template, email, email_action, event);


I tried with your code but unable to get the req for name



Chuck,



Same code was working when i try to for RITM table:



(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,


                  /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,


                  /* Optional GlideRecord */ event) {


                  // Add your code here


var ritm = new GlideRecord('sc_req_item');


if(ritm.get(current.sysapproval)){


var req_for = ritm.u_requested_for.name;


template.print(""+ritm.u_requested_for.name);


}


})(current, template, email, email_action, event);


Chuck,



I tried with below script and it works:



var req_for = ritm.u_requested_item.u_requested_for.getDisplayValue();



Thanks for all your help