The CreatorCon Call for Content is officially open! Get started here.

Roles value visible based on Client values on catalog item

Manohararuna
Tera Contributor

Hi Everyone,

I have one requirement on Catalog item 

--In catalog item having two variable, Client and Roles and roles having the option Functional and Basis and Client Having the options DS4 100 and DS4 200 ,DCA 100. If i select Functional in Roles then DS4 100 and DS4 200 and DCA 100 visible only (others not)and i i select Basis in Roles then in Client only visible DS4 100, DS4 200(only others not visible)for this i want to on change client script in serviecnow.

--same time if i Development option in scape variable and  S4 option in System variable then DS4 100 and DS4 200 options only visible in client variable.

Please help me write on-change client script on this

 

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@Manohararuna 

it's an easy requirement.

what did you start with and where are you stuck?

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

Rafael Batistot
Kilo Patron

Hi @Manohararuna 

Create Catalog Client Script > onChange

Roles:

(function onChange(control, oldValue, newValue, isLoading) {
  if (isLoading || !newValue) return;

  var options = [];
  if (newValue === 'Functional') {
    options = ['DS4 100', 'DS4 200', 'DCA 100'];
  } else if (newValue === 'Basis') {
    options = ['DS4 100', 'DS4 200'];
  }

  g_form.clearOptions('client');
  g_form.addOption('client', '', '-- None --');
  options.forEach(function(opt) {
    g_form.addOption('client', opt, opt);
  });
})();


System

(function onChange(control, oldValue, newValue, isLoading) {
  if (isLoading) return;

  var scape = g_form.getValue('scape');
  var system = g_form.getValue('system');

  if (scape === 'Development' && system === 'S4') {
    var options = ['DS4 100', 'DS4 200'];
    g_form.clearOptions('client');
    g_form.addOption('client', '', '-- None --');
    options.forEach(function(opt) {
      g_form.addOption('client', opt, opt);
    });
  }
})();



If you found this response helpful, please mark it as Helpful. If it fully answered your question, consider marking it as Correct.

Doing so helps other users find accurate and useful information more easily.