How to hide embedded list of outages (task_outage) on incident form

Milan13
Giga Expert

Hello,

I have an embedded list of outages on my incident form (please see below print screen) .

I only need this list to be visible for major incidents (major_incident_state = 'Accepted').

Any idea how to do this?

Many thanks, 

Milan

find_real_file.png

 

1 ACCEPTED SOLUTION

Hello Milan,

There is one field available on Client script isolated script. please add that field on this form and uncheck it.

Please check the below screenshot and yellow marked text.find_real_file.png

 

Now this script will definitely run.

Thanks,

Abhishek Gardade

Thank you,
Abhishek Gardade

View solution in original post

13 REPLIES 13

Omkar Mone
Mega Sage

Hi 

Have you gone through the link below?

https://www.servicenowguru.com/scripting/client-scripts-scripting/hiding-related-lists-embedded-list...

 

Also you can try an onLoad client script which would look something like this ,

 

function onLoad() {

	if (your condition) {
		g_form.setSectionDisplay("embedded_list",false);
	}

}

 

Mark correct if my answer helped you.

 

Regards,

Omkar Mone.

www.dxsherpa.com

Hi Omkar,

how do I determine the "embedded_list" argument in below function - its embedded list sourced from "task_outage" table but this argument does not work...

 

Many thanks,

Milan

	g_form.setSectionDisplay("embedded_list",false);

Hi 

Check the below Screenshot how it is done :

find_real_file.png

 

Remember to uncheck the Isolate script checkbox so that we can go ahead with the DOM manipulations. PFB the script :- 

 

function onLoad() {
	var sections=g_form.getSections();
	for (var i=0;i<sections.length;i++)
	{
		var embedded_elements=sections[i].getElementsByClassName("embedded");
		// Loop through those elements and when we get a valid match of the table name of the embedded list we hide it
		for (var i_element=0;i_element<embedded_elements.length;i_element++)
		{
			embedded_elements[i_element].hide();
		}
	}
}

 

Regards,

Omkar Mone.

www.dxsherpa.com

Hi 

Can you mark correct answer if I have resolved your query to close this thread?

 

Regards.