Hiding Form Sections Without Using GlideForm setSectionDisplay

austindoorlag
Tera Contributor

Hello ServiceNow enthusiasts,

 

Is anyone familiar a way to hide a section of a form without using syntax of the form:

g_form.setSectionDisplay(FORM_NAME, false);

In particular:  is there some low code way to do this?  I'm not familiar with anything, and a quick look through the documentation doesn't seem to show anything, but I wanted to get a second opinion from the community here.

 

Background:

I'm trying to debug an issue where a section on a form is being hidden inappropriately.  I'm not sure what script is responsible for hiding this section and I'd like to find out.  My current approach is going to be something along the lines of:

  1. Set a breakpoint in the setSectionDisplay function
  2. Open the form
  3. Thoroughly inspect the call stack for each usage of setSectionDisplay until I can find what script is responsible for hiding the section

I'm fairly convinced this should work if setSectionDisplay is the only way of hiding a section in a form.  Hence the question:  does anyone know of any other ways of hiding a form section that I should be worried about?

1 ACCEPTED SOLUTION

jcmings
Mega Sage

I believe scripting it is the only way. You can search the Execute if true or Execute if false fields on the UI Policy table for setSectionDisplay (after filtering to your specific table of course)... may also be worth checking client scripts... and also confirm that you aren't just in a View that doesn't have the section.

 

Edit to add: you could also probably find this super quickly by using the Studio code search (or SNUtils /code command).

View solution in original post

3 REPLIES 3

jcmings
Mega Sage

I believe scripting it is the only way. You can search the Execute if true or Execute if false fields on the UI Policy table for setSectionDisplay (after filtering to your specific table of course)... may also be worth checking client scripts... and also confirm that you aren't just in a View that doesn't have the section.

 

Edit to add: you could also probably find this super quickly by using the Studio code search (or SNUtils /code command).

@jcmings Thanks a ton for your thoughts here.

I believe I have a good idea on how to figure out what scripts may be using the setSectionDisplay functionI'll keep the SNUtils/VSCode solution in the back of my head as well -- thank you!

Your line of thinking pretty much exactly matches with my own.  Since I was mostly just looking for a second opinion on this going to accept your solution as correct.  I'll make it a point to update this thread if I find something unexpected. 

AustinD08141749
Tera Contributor

Just wanted to follow up in case anyone might run across this again:

I found that my particular bug was due to an inappropriate usage of the GlideForm setSectionDisplay function.  I didn't end up setting a breakpoint in that function definition however.

I ended up using a strategy I had forgotten about when I originally made this forum post:  DOM Breakpoints on the HTML element in question (i.e. the tab that was being hidden inappropriately.)  From there I was able to figure out what script was responsible for hiding the tab by using a sys_id that's appended to the function name in ServiceNow's minified client source code.  If I hadn't been able to find the script from that sys_id:  this could've been a good opportunity to use the SNUtils code search that @jcmings mentioned above, since I knew the contents of the code, but I certainly feel like I got a bit lucky finding that sys_id in the function name -- I don't know if the same situation applies to UI Policies.


As I suspected:  the culprit here was a buggy client script.