How to pass current record field values in the Reference qualifier script include call

anushad
Tera Expert

I have a reference field "B" whose list is based on value of the Field A which is another Reference field. I added Advance reference qualifier which calls a script include and passes on Field A value (sys_id), something like this

sys_idINjavascript: new x_scopedapp.getB().getBA(current.a);
script include: client callable , All Application access

var getB = Class.create();
getB.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {

getBA: function(a){

var valueOfA = a;
var tr= []; // to store sys_ids of the field B
var GR = new GlideRecord('x_scoped_table'); ( Gliding a m2m relationship table between Field A and Field B)
GR.addEncodedQuery('a='+valueOfA);
GR.addQuery('active',true);
GR.query();
while(GR.next()){
tr.push(GR.tr.toString());
}
return tr; // sys ids of field B 
},
type: 'getB'
});

 

But its throwing an error current is not defined. How can i pass a current record field values to a script include ??

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Anusha,

Any update on this?
Can you mark my answer as correct, helpful if you were able to achieve the requirement. This helps in removing this question from unanswered list and helps users to learn from your thread. Thanks in advance.

Regards
Ankur

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

View solution in original post

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

there should not be an issue while using current.a

can you check whether log is coming or not for current.a

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

no what i see in logs in current is not defined. Check the attachment

Hi Anusha,

can you share the screenshot of the dictionary where you are calling that?

Regards

Ankur

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

Hi Anusha,

Update your ref qualifier as below and script include as below and check once

javascript: new x_scopedapp.getB().getBA(current.a);

script include

var getB = Class.create();
getB.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {

getBA: function(a){

var valueOfA = a;
var tr= []; // to store sys_ids of the field B
var GR = new GlideRecord('x_scoped_table'); ( Gliding a m2m relationship table between Field A and Field B)
GR.addEncodedQuery('a='+valueOfA);
GR.addQuery('active',true);
GR.query();
while(GR.next()){
tr.push(GR.tr.toString()); 
}
return 'sys_idIN' + tr; // sys ids of field B 
},
type: 'getB'
});

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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