show/hide section based on assignment group name
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2023 01:16 PM
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2023 08:19 PM
you want to make section name dynamic? why?
you are sure which section to show/hide based on group
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 04:39 PM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2023 08:29 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 04:54 PM
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 10:31 AM
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