Reference qualifier on the record producer

Kaustubh k
Tera Contributor

Hi All,

 

Thanks for checking my post.

We have reference qualifier in the incident form on a custom field  service  as :

javascript:new incidentServerUtils().getService(current.caller_id);

 

which triggers;

var incidentServerUtils = Class.create();
incidentServerUtils.prototype = {
    getService: function(cur) {
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id',cur);
gr.query();
if(gr.next()){
var assigneeLoc = gr.location.country;
}
return 'u_location='+assigneeLoc+'^ORu_location=';
    },
    type: 'incidentServerUtils'
};
 
Now when i am trying to use the same in Record producer filed which has variable service, its not taking up the further flow and not triggering the logic in Script include.
 
looking forward for a feedback on this.
 
Thanks
Karan
 
 
1 ACCEPTED SOLUTION

Pravindra1
Tera Guru

Hi @Kaustubh k ,  To get the field value in Record producer, need to use variables.<Field/Variable Name>.

 In your use case, It should work when you replace the "current.caller_id" to "current.variables.caller_id" in reference qualifier.

javascript&colon;new incidentServerUtils().getService(current.variables.caller_id);

 

View solution in original post

5 REPLIES 5

Mallidi Suma
Tera Guru

Hi @Kaustubh k ,

 

In your script, you are sending current.caller_id to the server side script as a parameter to script includes. This will work with form reference field Reference Qualifiers.

 

javascript&colon; new incidentServerUtils().getService(current.caller_id);

 

But I have observed, this won't work to Reference fields in variables in Catalog Items. So as a workaround Instead of sending the parameter you can use the gs.getUserID() function in your script include.

 

Please mark my answer as helpful, if it helps you!!

Hello @Mallidi Suma 

Thanks for reviewing this, could you please help with the SI changes and also the ref qualifier to me modified on the field,which triggers the SI.

 

var incidentServerUtils = Class.create();
incidentServerUtils.prototype = {
    getService: function(cur) {
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id',cur);
gr.query();
 
and refernce qualifier changes on : javascript&colon;new incidentServerUtils().getService(current.caller_id);

 

 

KB18
Tera Guru
Tera Guru

Dear @Kaustubh k 

You can use OnDemand Script Include to achieve your requirement.

 

For reference: Advanced Reference Qualifier Using a Script Include - ServiceNow Guru

Please hit the thumb Icon and mark as correct in case I help you with your query!!!
- Kailas

Ankur Bawiskar
Tera Patron
Tera Patron

@Kaustubh k 

the reference variable is referring to which table?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader