How to visible the section based on the subcategory or assignment group to visible the section.

praveen50
Tera Contributor

I have created record producer.In target record i have created one custom section and one field (i.e unmandatory).

i want to visible the my custom section and under the field should be mandatory in when subcategory is "Release" and Assignement group  is "GRC solution" in target record.

could you please help me on this.

4 REPLIES 4

OlaN
Giga Sage
Giga Sage

Hi,

Depending on your requirement, you can create either a Catalog UI Policy, or a UI policy, with UI policy actions to hide/unhide sections and fields.

Musab Rasheed
Tera Sage
Tera Sage

Hello,

Use client script for that, see this blog, just add your field as well in same script

https://servicenowguru.com/scripting/client-scripts-scripting/showhide-form-section/

Please explore.

Regards

Please hit like and mark my response as correct if that helps
Regards,
Musab

Harish KM
Kilo Patron
Kilo Patron

Hi write a onChange client script on field SubCategory:

Script:

function onChange(control, oldValue, newValue, isLoading) {
   //this example was run on a form divided into sections (Change form)
   // and hid a section when the "state" field was changed
   var sections = g_form.getSections();
   var subCat = g_form.getValue('subcategory');
   var group = g_form.getValue('assignment_group');
   alert(sections); // check your section name you want to hide
   if (subCat == '2' && group == 'sysid of group') {
      g_form.setSectionDisplay(sections[1], true);
   } else {
      g_form.setSectionDisplay(sections[1], false);
   }
}

Refer : https://docs.servicenow.com/bundle/sandiego-application-development/page/app-store/dev_portal/API_reference/GlideForm/concept/c_GlideFormAPI.html#r_GlideFormGetSectionNames
Regards
Harish

umaaggarwal
Giga Guru
Giga Guru

Hi Harish,

 

What do you mean by target record ? Is it the record created in target table ? If yes, you cannot use catalog ui policy . so use normal ui policy and use ui policy script to show/ hide section and making the field mandatory 

The line of code which hides a section is :

g_form.setSectionDisplay('section_name', false);

 

You can use this with the conditions you want to put in.

If helps, Please mark correct and helpful

 

Regards!

Uma