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

Prins Kumar Gup
Giga Guru

Hi,

1. I have updated your reference qualifier see the below: if you used this code in catalog item that time you will write the        "current.variables.field_value" or if you used in the table that time you will write the only "current.field_value"

javascript: new x_scopedapp.getB().getBA(current.field_value);// I removed the sys_idIN

2. Make the client callable checkbox is false in script include.

   client callable=false

"It's working fine for me"

Please Hit like, Helpful or Correct depending on the impact of the response if this solves your query!!

Thanks,

PKG

 

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