Reference qualifier
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2024 04:31 AM
How can we script a variablr reference qualifier to show variable drop down only if depended value is not empty. Eg-variablr should show user assigned assets based on username. Currently without selecting user name all assets are showing it should be empty if no user name selected.
Ps - we are not aiming to use ui policy to make readonly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2024 05:26 AM
Does your Reference qualifier look similar to this
or are you calling a Script Include and function that is returning a list of sys_ids?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2024 05:37 AM
Thanks Brad for reply.
The qualifier looks similar with calling function inside script including and passing current variablr from catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2024 05:47 AM
OK, so then in the Script Include just be sure to return an empty list if the argument passed into the function is empty. I usually do this by declaring an empty array at the beginning
var answerArr = [];
then the GlideRecord pushes sys_ids from the target table into the array for records that match the argument (assets belonging to a user in your case). Wrap your GlideRecord in an if block to only execute if the argument is not blank so that it doesn't return all assets without an assigned user, if you don't want to see those. Then when the joined array is returned with something like this
return 'sys_idIN' + answerArr.join(',');
you'll be returning sys_idIN blank in this case, instead of a list of records that you didn't want, or if you have it coded differently, returning nothing, or something that the qualifier can't interpret, which results in showing all of the records.