populating list collector variables with a client catalog script

JD Draper
Kilo Explorer

I have a catalog item with multiple list collector variables and regular variables.  I am trying to create a defined set of variable values to be populated automatically when the specific profile is selected. I am using catalog client script, based on information I have gleaned from the forums, but the fields are not populating.  I have, (I believe) , set the list collection variable attribute to 'glide_list'

function onChange(control, oldValue, newValue, isLoading) {

    if (isLoading || newValue == '') {
        return;
    }

    var profileObj = g_form.getValue(newValue,'set_profile_selection');
    
   //Basic AP Accountant Role
   if (profObj == 'Accounting - AP Accountant') {
   g_form.setValue('asset_management_roles', 'f04af62fdb7f4110589be525ca961973');
   g_form.setValue('business_objects_roles', 'a3d60be7db338110589be525ca9619f9,d1578fe7db338110589be525ca9619e6, f2b847abdb338110589be525ca9619b1');
   g_form.setValue('purchasing_roles', '132c4dc0db8c9510589be525ca9619d6');
   g_form.setValue('accounts_payable__roles', '3e3b0b23db738110589be525ca961946,696c8f2bdb738110589be525ca961973,db1e4723dbb38110589be525ca96199a,3a3e47efdb738110589be525ca96198a,34dec7efdb738110589be525ca961927');
      return;
   }    
}

Any help would be appreciated

7 REPLIES 7

Ian Mildon
Tera Guru

I have not tried doing this kind of thing via a Client Script, but via Business Rules with "push" and "join" commands.

I did do a quick web search for Client Script examples and found this link that you might find helpful:

https://www.basicoservicenowlearning.in/2021/09/list-collector.html

JD Draper
Kilo Explorer

So, for the benefit of everyone else.  The script is correct after fixing the variable name in the if statement; however, the UI Type was set to desktop only. After changing to Mobile/Service Portal, everything started working.

Hey @JD Draper ,

Glad that it worked out,

Feel free to mark correct if my response helped you fix your issue 🙂

Best Regards
Aman Kumar