Add specific users to a List Collector

ceraulo
Mega Guru

Hello!

I have a catalog item with a list collector variable.

I want to populate this variable with specific users (ex. User A, User B, User C). I've tried using the below (Catalog Client Script) using system properties but it does not work.

function onSubmit() {    
        g_form.setValue('list_collector_variable', 'sysprop_sysid1, sysprop_sysid2, sysprop_sysid3');
}

Please help!

Thank you.

1 ACCEPTED SOLUTION

@ceraulo 

store the comma separated sysIds in system property and use it

javascript: gs.getProperty('propertyName');

Regards
Ankur

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

View solution in original post

8 REPLIES 8

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

why not give default value as comma separated sysIds of those users in that variable configuration?

no script required

Regards
Ankur

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

@ceraulo 

store the comma separated sysIds in system property and use it

javascript: gs.getProperty('propertyName');

Regards
Ankur

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

HI @Ankur Bawiskar, I used this to populate the variable on creation of the sctask. I then created a catalog client script to clear the variable if a particular condition is met.

Thank you.

Hi @Ankur Bawiskar, I want to do it using a catalog client script because there is a condition for the users to be added. I've updated the script I shared earlier. 

function onSubmit() { 

        var cond = g_form.getDisplayValue('some_reference_variable'); 

        if (cond == 'ServiceNow') {
g_form.setValue('list_collector_variable', 'sysprop_sysid1, sysprop_sysid2, sysprop_sysid3');
}
  
        
}