show/hide section based on assignment group name

archie5
Tera Expert

I want to make a section visible on the form based on assgn group name. Let's say I have 2 groups A and B, and two sections with same name A and B
Section A should be visible only when group A is selected, B section only when Group B is selected and so on
Section name will be same as group name. How to not hard code this so that this works even when more groups and sections (of same names) are added. Thank you!

13 REPLIES 13

@archie5 

you want to make section name dynamic? why?

you are sure which section to show/hide based on group

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

Hi @Ankur Bawiskar yes I know same section will be called as the group name. Let's say I have 2 groups IT and HR, so the two sections will be with the same name IT and HR.
Section IT should be visible only when group IT is selected, HR section only when Group HR is selected and so on.

Section name will be same as group name. And in future more groups and sections will be added. Like Group Legal and section Legal. Use case is - we have common fields on the form for all groups and field related to the groups (which should be visible only to them) will be in the sections.

I have created mappings in sys properties like 'HR': 'group sys id'. I know I can use g_form.setSectionDisplay('section_name', true) in client script. But what do I write in the script include to make this whole thing dynamic?

 

Ravi Chandra_K
Kilo Patron
Kilo Patron

Hello @archie5 

Greetings!

use g_form.setSectionDisplay('section_name', true); in your client script.

Please hit the thumb and Mark as correct based on Impact!!

 

Kind Regards,

Ravi Chandra.

 

DanielCordick
Mega Patron
Mega Patron

this may be able to help you

https://www.servicenow.com/community/developer-articles/how-to-using-ui-policies-to-hide-form-sectio...

If this helped in anyway please mark helpful and or correct! 

 

did you figure this out?

 

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response helped in any way