How to display the section/tab in incident form ?

NK32
Kilo Expert

Hi Team,

I would like to display the section/tab(Security Incident) when the 'Incident Type' is chosen 'Security Incident'.
The section/tab(Security Incident) should be hidden when the 'Incident Type' is not chosen 'Security Incident'.

Client script :

Type: Onchange
function onChange() {
var sections = g_form.getSections();
if(g_form.getValue("u_template") == "Security Incident"){
sections[5].style.display='none';
}else{
sections[5].style.display='block';
}
//g_form.setSectionDisplay('Security Incident', false);
}

Kindly assist on this please

Regards,
NK

1 ACCEPTED SOLUTION

Ashish Dhole2
Kilo Expert

Try below script

//Type: Onchange
function onChange() {
g_form.setSectionDisplay('security_incident', false)
if(g_form.getValue("u_template") == "Security Incident")
{
  	g_form.setSectionDisplay('security_incident', true);
}
else
{
	g_form.setSectionDisplay('security_incident', false);
}

}

View solution in original post

8 REPLIES 8

the changes which i had suggested did not work ?

Unfortunately, it didn't work for me

it's working perfectly fine at my end. 

thanks for participating on community. 

 

Astrid Sapphir1
Giga Expert

Hi NK,

If you would prefer to use the g_form.setSectionDisplay function (which I personally find neater), the parameters should be ('security_incident',false) or true.

g_form.setSectionDisplay('security_incident',true);
g_form.setSectionDisplay('security_incident',false);

This is because the name value is the lower-case letters and whitespace replaced with underscores, much like a Label-Name relationship for a field or Catalog Item variable if the label is written first.

Otherwise the logic seems sound, and Harshvardhan's solution should function also.

Kind Regards,

Astrid