Best way to hide an entire form

Rob Sestito
Mega Sage

Hello SN Comm,

I am trying to come up with a good way to hide an entire form at will - where the user can do so for themselves when working on a form.

Here is what I have going on with a form called Demand Planning:

find_real_file.png

When Proceed to Form 2 is checked, Effort section appears, and same concept happens when checking Proceed to Form 3. When both 'Proceed' fields become true, they will be read-only. That will eliminate the user from unchecking Proceed to Form 2, which can make the form collapse section 2 but still see section 3.

I wanted to see about creating some sort of action at the top of the form, to collapse entire form (in case the user wants to minimize everything together).

Any Suggestions as to what I can / should do?

Thank you!

~Rob

1 ACCEPTED SOLUTION

Rob Sestito
Mega Sage

I was able to figure out a nice UI Policy Script to handle the Form how I wanted it to and it works great!

Here is what I did below, if anyone feels like trying to use this:

find_real_file.png

 

find_real_file.png

 

Thanks everyone who helped out!

~Rob

 

View solution in original post

11 REPLIES 11

Alberto Consonn
ServiceNow Employee
ServiceNow Employee

Hi Rob,

maybe you could easily use the standard Collapse/Expand functionality in the Forms as described below:

Groups related information on the form. To enable or disable form tabs, click the gear icon in the banner frame (Settings icon) and toggle the Tabbed forms option.

Users can use icons to collapse (collapse form section icon) or expand (expand form section icon) form sections when tabbed forms are disabled. When you collapse or expand a form section, your selection is saved as a user preference. The next time you access a record that uses the same form, the same sections are collapsed or expanded.

Check the documentation here: Forms

Hope this will fit your need.

If I have answered your question, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.

Thanks you

Cheers
Alberto

Hey Alberto,

Thanks for replying - and I have looked into that before. However, it does that style for everything, and we do not want that. All tabs are taken away and become the arrow style. And that just does not go over well for all our forms when using HR Case Management.

Thank you for the suggestion though!

~Rob

Rob Sestito
Mega Sage

I am thinking I could just use a UI Policy - but rather than picking each field one by one. I would like to run a script instead - but need to look through all the fields on this table (which is small).

Anyone able to help with a script to loop through all fields on the table, and when a True/False field condition is True, the script can run and hide all fields EXCEPT the True/False field that will be controlling this condition. Which is called Collapse / Expand Form.

Thank you!

~Rob

Rob, I'm not sure I understand your end game here, but you can hide section via Client Script (or I suppose in the Script section of a UI Policy).  Here is an example I use to hide two different Sections of our Incident form onLoad:

 

function onLoad() {
   //Type appropriate comment here, and begin script below
   var high = g_form.getValue('u_highest_priority');
	var res = g_form.getValue('resolved_at');
	var sitres = g_form.getValue('u_resolved');
	var pri = g_form.getValue('priority');
	
	if ((pri == '1' || pri == '2' || high == '1 - Critical' || high == '2 - High')){
		g_form.setSectionDisplay('situation_management',true);
		g_form.setSectionDisplay('tir',true);
	}
	
	else{
		g_form.setSectionDisplay('situation_management',false);
		g_form.setSectionDisplay('tir',false);
	}
}