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

How to make groups visible based on other fields

Chahak kindra
Tera Contributor

I have two fields Test1 &TEST2 both are yes/no type.If both are no then groups of type ITSM should appear in catalog item in service portal l.How to achieve this and group is select box type

 

 

 

 

 

3 REPLIES 3

mujeebqasimi
Giga Contributor

 

 

you can make it work with just two onChange catalog client scripts, one for each Yes/No field.

Each script checks both Test1 and Test2 values , if both are “Yes,” it sets the group field to ITSM, 

Depending on your use case, you might also want to run it onLoad to handle pre filled values.

example for field test1

if (newValue === 'Yes' && g_form.getValue('test2') === 'Yes')
g_form.setValue('group', 'ITSM');


vignesh parthib
Tera Guru

Hi @Chahak kindra 

 

Create onChange Catalog client script 

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

  var test1 = g_form.getValue('test1');  // 'true' or 'false'
  var test2 = g_form.getValue('test2');

  var showGroup = (test1 === 'false' && test2 === 'false');
  g_form.setDisplay('group', showGroup);

  if (!showGroup) {
    g_form.clearValue('group');
  }
}

 

Thanks,
Vignesh
"If this solution resolves your issue, kindly mark it as correct."

 

Ankur Bawiskar
Tera Patron
Tera Patron

@Chahak kindra 

so what did you start with and where are you stuck?

you didn't share any scripts and screenshots etc

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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