filter table field from client script

Snow Tomcal
Tera Expert

Hi All,

I want to filter a reference field. I created a script include that query the table and return the filtered table.

How do I use the returned data in the client script?

Thanks in advanced 🙂

 

4 REPLIES 4

Brad Bowman
Kilo Patron
Kilo Patron

The typical/best way to use a Script Include to filter a reference field is to call it in the reference qualifier:

javascript<<colon>> new scriptIncludeName().functionName();

if the SI needs the value of other field(s) include them in the function call:

javascript<<colon>> new scriptIncludeName().functionName(current.name, current.number);

The SI needs to return 'sys_idIN' + arr.join(',') where arr is the array of sys_ids for the referenced table that the SI has built.

I tried it but the current.field_name is undefiend when I try to use it from the script include. 

Passing in current.field_name, as an example in the Reference Qualifier, in your Script Include, with the Client callable box checked, the functionName call needs to contain an argument or whatever it's called - like (fieldName) in the parenthesis following the function name, then you can use fieldName as a script variable.  If it's still not working for you after checking these things, post your reference qualifier and Script Include, and we'll get it sorted.

AnubhavRitolia
Mega Sage
Mega Sage

Hi @Snow Tomcal 

 

Can you example little more that which field you want to filter and refers to which table.

 

Also the code you have written for Script Include.

 

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023