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,

Below please find link to ServiceNow docs for more detailed info on 

setSectionDisplay(String sectionName, Boolean display)

Shows or hides a section.

Parameters:

NameTypeDescription
sectionNameStringThe section name is lower case with an underscore replacing the first space in the name, and with the remaining spaces being removed, for example "Section Four is Here" becomes "section_fourishere". Other non-alphanumeric characters, such as ampersand (&), are removed. Section names can be found by using the getSectionNames() method.
displayBooleanWhen true shows the section. When false hides the section.

Return:

TypeDescription
BooleanReturns true when successful.
 

https://developer.servicenow.com/dev.do#!/reference/api/orlando/client/c_GlideFormAPI#r_GlideFormSet...

 

- Pradeep Sharma

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