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.

current.variables not working in business rule or background script

Julian12
Mega Guru

So Im trying to get the sys id of a reference record inside a catalog item so to do a query inside a table with that sysid and return a value inside another variable on the opened ticket.

But I'm not getting the proper reference value or sysid from the variable, I know its the variable im not getting since when i script the sysid on the query it returns as espected...

Any ideas on what Im doing wrong??? I'm testing on background scripts

 

 

var current = new GlideRecord('sc_req_item');
current.get('f7f850b11b6875109dbded7be54bcbbd');


var perfil = current.variables.qual_perfil;
var gr = new GlideRecord ('u_m2m_access_profi_software_pac');
gr.addQuery('u_access_profile','3a082d0f1b0e89109dbded7be54bcb96');
gr.query();

gs.log('perfil '+ perfil);


if(gr.next()) {
gs.log('registro ' + gr.u_access_profile.u_profile);
// current.variables.hidden_grupo_ad = gr.u_access_profile.u_profile;
}

else gs.log ("erro")



1 REPLY 1

Julian12
Mega Guru

Even more simple, its not working, returns undefined :

var current = new GlideRecord('sc_req_item');
current.get('f7f850b11b6875109dbded7be54bcbbd');


var perfil = current.variables.solicitacao;

    gs.log('perfil> '+ perfil);