filter table field from client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2023 01:45 AM
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 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2023 03:38 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2023 11:55 PM
I tried it but the current.field_name is undefiend when I try to use it from the script include.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2023 05:30 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2023 12:20 AM
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.
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023