- 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:37 AM
Log what the value from "current" in the:
javascript: new ScriptIncludeName().functionName(current)
It looks like you are putting the sys id of the user in the list collector and comparing to the HR Case sys id. You can verify that by adding some logs to the script include to see what it gives you
you can use
gs.info('Srinath9: ' + current);
and then review the value from:
https://your-instance.service-now.com/syslog_list.do?sysparm_query=sys_created_onONToday%40javascript%3Ags.daysAgoStart(0)%40javascript%3Ags.daysAgoEnd(0)%5EmessageLIKESrinath9&sysparm_view=
/* If my response wasn’t a total disaster ↙️ ⭐ drop a Kudos or Accept as Solution ✅ ↘️ Cheers! */
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2025 01:39 AM
And I can see some typeos:
javascript:new ScriptIncludeName().functionName(current)
- if(current.sys == 'sys_id_of_a_certain_hr_case'){
- current.sys does not exist and it is nonsense
var optGr = new GlideRecord('table_from_which_options_are_referred');
- is this just anonymization of your script that is shared or you are really using this...?
/* If my response wasn’t a total disaster ↙️ ⭐ drop a Kudos or Accept as Solution ✅ ↘️ Cheers! */
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2025 02:57 AM
@GlideFather ,
My bad that there were some typos, yeah, as I mentioned it's a model script, not the exact script which I used. current.sys_id == 'hr_case_sys_id' this is the format with which the script is. And we tried to log the table name and sys id, result is - the table name was 'sc_cart_item' and some sys ID also came but if we check with that sys id in the sc_cart_item table, the result is none, meaning no such records with that sys id in the sc_cart_item table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2025 03:09 AM
but why would you use sc_cart_item? it is temporary data before the submission
You mention HR Case and then sc_cart_item, those are different things, even different from sc_request > sc_req_item > sc_task
Are you sure you know what data do you want to get and from what table/record exactly?
/* If my response wasn’t a total disaster ↙️ ⭐ drop a Kudos or Accept as Solution ✅ ↘️ Cheers! */