- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2025 01:17 AM
Hii everyone,
We need to show an extra/additional option to a List Collector variable in an HR case form (variable's in separate section, not on HR case form), but only for a specific HR case record. The List Collector pulls options from another table using type specifications and a reference qualifier. We've implemented a script include in the ref qualifier at the variable end to handle this, but it's always hitting the 'else' condition instead of 'if'. Any suggestions to fix this would be appreciated!
Reference qualifier script at the variable:
javascript:new ScriptIncludeName().functionName(current)
Script Include:
functionName: function(current){
var answer = '';
var optSysID = [];
var optGr = new GlideRecord('table_from_which_options_are_referred');
if(current.sys == 'sys_id_of_a_certain_hr_case'){
optGr.addEncodedQuery('query1');
}
else{
optGr.addEncodedQuery('query2');
}
optGr.query();
while(optGr.next()){
optSysID.push(optGr.sys_id.toString);
}
answer = 'sys_idIN' + optSysID;
return answer;
If there is any modification is required or if there is any other approach, please let me know.
Thanks,
Srinath
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2025 02:51 AM
I updated the corresponding record in question_answer table with the additional option's Sys ID so that the additional option is in the Selected slush bucket.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2025 01:44 AM
please share how and from where is this script include called?
So it's a list collector variable and on HR case record you want to show extra option?
If yes then your script needs some modifications
try this once
functionName: function(current) {
var answer = '';
var optSysID = [];
var optGr = new GlideRecord('table_from_which_options_are_referred');
if (current.sys_id == 'sys_id_of_a_certain_hr_case') {
optGr.addEncodedQuery('query1');
} else {
optGr.addEncodedQuery('query2');
}
optGr.query();
while (optGr.next()) {
optSysID.push(optGr.sys_id.toString);
}
answer = 'sys_idIN' + optSysID;
return answer;
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2025 02:50 AM
@Ankur Bawiskar ,
That script include is called at the list collector variable's reference qualifier and this variable is not on the HR case form, it's included in a separate section associated on the HR case form. Below is the model script which we have used in the reference qualifier of the variable,
javascript:new ScriptIncludeName().functionName(current)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2025 02:56 AM
you are adding reference qualifier on field or variable? share some screenshots
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2025 03:02 AM - edited 06-05-2025 03:03 AM
@Ankur Bawiskar,
As I don't have it with me in my PDI, I can't provide a screenshot. But I can say that I added that script include at Variable's reference Qualifier and not on the field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2025 03:10 AM
then please share what came in log in script include? were you able to pass sysId?
Sorry but you didn't gave your exact business requirement and screenshots.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader