List Collector Variable -Additional option to specific single HR Case

Srinath9
Tera Guru

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

 

1 ACCEPTED SOLUTION

Srinath9
Tera Guru

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.

View solution in original post

10 REPLIES 10

Ankur Bawiskar
Tera Patron
Tera Patron

@Srinath9 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@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)

 

 

@Srinath9 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@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.

 

@Srinath9 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader