- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2024 07:44 AM
I'm wanting to hide the Preferences section from the Project Task form (pm_project).
From what I'm seeing there's no clear/easy way to flip an Active field like a lot of things on forms.
Is there a simple solution to hiding form sections?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2024 08:51 AM - edited 01-11-2024 08:53 AM
Hi @MBarrott,
This is easily resolved by leveraging the following method via a UI Policy or a Client Script. (UI Policy is best practice)
//Example code snippet using the incident form and the 'Resolution Information' Tab/Section
Tip: The section name is lower case with an underscore replacing the first space in the name, and with the remaining spaces being removed, for example, "Section Four is Here" becomes "section_fourishere". Other non-alphanumeric characters, such as ampersand (&), are removed. Section names can be found by using the getSectionNames method.
To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Helpful.
Thanks, Robbie
If you need advice or guidance on how to set up a UI Policy, see the following link: https://docs.servicenow.com/bundle/vancouver-platform-administration/page/administer/form-administra...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2024 08:45 AM
This can be achieved by creating an On Load Client Script on the form and using GlideForm method setSectionDisplay.
For example:
g_form.setSectionDisplay('notes',false);
Replace Notes by the section name such that the section name is lower case with an underscore replacing the first space in the name, and with the remaining spaces being removed, for example "Section Four is Here" becomes "section_fourishere". Other non-alphanumeric characters, such as ampersand (&), are removed. Section names can be found by using the getSectionNames() method.
If you found this helpful, please mark this reply as solution.
Regards,
Manik Modi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2024 08:51 AM - edited 01-11-2024 08:53 AM
Hi @MBarrott,
This is easily resolved by leveraging the following method via a UI Policy or a Client Script. (UI Policy is best practice)
//Example code snippet using the incident form and the 'Resolution Information' Tab/Section
Tip: The section name is lower case with an underscore replacing the first space in the name, and with the remaining spaces being removed, for example, "Section Four is Here" becomes "section_fourishere". Other non-alphanumeric characters, such as ampersand (&), are removed. Section names can be found by using the getSectionNames method.
To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Helpful.
Thanks, Robbie
If you need advice or guidance on how to set up a UI Policy, see the following link: https://docs.servicenow.com/bundle/vancouver-platform-administration/page/administer/form-administra...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2024 12:41 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2024 07:38 AM - edited 01-12-2024 09:32 AM
Hi @MBarrott,
The statement looks correct. Can you clarify if you have any conditions in the 'When to Apply' tab of the UI Policy? Also, confirm you have the 'Reverse if false' checkbox unchecked.
To confirm the UI Policy is running when expected, add the following line in the onCondition function above the g_form statement. We will of course remove this pop-up once we've confirmed the UI Policy is running as expected.
function onCondition() {
alert('Running Hide Display UI Policy'); //Remove this once we've confirmed the UI Policy is running
g_form.setSectionDisplay('preferences', false);
}
To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Helpful.
Thanks, Robbie