Hide/Show Related Tab Named-"Resolution Information "?

Swetha18
Tera Contributor

Hide/Show Related Tab Named-"Resolution Information "
1- Related Tab Named-"Resolution Information " by default should be hidden.
2- Related Tab Named-"Resolution Information " visible when the incident state is "Resolved".
3- Under Related Tab Named-"Resolution Information " field Named- "Resolution code" and "Resolution notes" also mandatory when the incident state is "Resolved".

I am new to service now,I don't know if Resolution Information have any back end name, i was not able to find it. So correct my code to get the output.

Client Script ...onChange...Field..state...

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }
    if(newValue=='1'){
 g_form.setVisible('Resolution Information',false);

 }

g_form.setVisible('close_code',false);
 g_form.setVisible('close_notes',false);

 if(newValue=='6'){
 // g_form.setVisible('Resolution Information',true);
g_form.setMandatory('close_code', true);
    g_form.setMandatory('close_notes', true);
 } 
}

1 ACCEPTED SOLUTION

Kunal Varkhede
Tera Guru

Hi,

 

In addition to above points

try below

 

OnChange client script on incident State

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {

//This onchange client script will work on onLoad also

if (newValue == '') //remove isLoading and change newValue === to newValue ==
{
return;
}


if(newValue=='1')//if incident state is new then hide releted tab resolution information

{
g_form.setSectionDisplay('resolution_information', false);

}

g_form.setDisplay('close_code',false);
g_form.setDisplay('close_notes',false);

if(newValue=='6'){
g_form.setSectionDisplay('resolution_information', true);
g_form.setMandatory('close_code', true);
g_form.setMandatory('close_notes', true);
}
}

 

 

Thanks,

Kunal

View solution in original post

6 REPLIES 6

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hello Swetha,

You need to use g_form.setSectionDisplay('resolution_information', false), to hide the section.

Here is the complete script.

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }
    if(newValue=='1'){
g_form.setSectionDisplay('resolution_information', false);

 }

g_form.setVisible('close_code',false);
 g_form.setVisible('close_notes',false);

 if(newValue=='6'){
 g_form.setSectionDisplay('resolution_information', true);
g_form.setMandatory('close_code', true);
    g_form.setMandatory('close_notes', true);
 } 
}

Pratiksha Kalam
Kilo Sage

Hello,

If this is tab that name you have mentioned in script should be"resolution_information".

 


var sectionM = g_form.getSections();
g_form.setSectionDisplay('resolution_information', false);

 

If my answer is useful mark correct!

 

Br,

pratiksha.k

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

please find responses to points below

I believe point 3 is OOB; so it should work it makes both the fields as mandatory when state changes to resolved

for script give this to hide section

g_form.setSectionDisplay('resolution_information', false);

for showing section use this

g_form.setSectionDisplay('resolution_information', true);

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader