- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2019 08:46 AM
On our change form, we are adding a tab specifically for application type change requests (as opposed to our infrastructure changes). We would like to have this tab be hidden unless someone chooses "Application" in the 'Class' field:
I tried using the instructions from this blog post, but the Application tab is still showing no matter what is chosen in the Class field. Below is the script I have:
Pasted as text:
[To show the tab when "Application" is chosen]
function onCondition() {
g_form.setSectionDisplay('application', false);
//Show the section
var section = $$('span[tab_caption_raw="Application"]')[0].select('span[id*=section.]')[0];
section.show();
//Show the tab
$$('.tab_caption_text').each(function(caption) {
if(caption.innerHTML == 'Application'){
caption.up('.tab_header').show();
}
});}
[To hide the tab when "Application" is not chosen]
function onCondition() {
g_form.setSectionDisplay('application', false);
//Hide the section
var section = $$('span[tab_caption_raw="Application"]')[0].select('span[id*=section.]')[0];
section.hide();
//Hide the tab
$$('.tab_caption_text').each(function(caption) {
if(caption.innerHTML == 'Application'){
caption.up('.tab_header').hide();
}
});
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2019 12:04 PM
Lets start with minimum code in both true and false code blocks
Make sure active=true, reverse if false = true
for the true code block use
function onCondition() {
g_form.setSectionDisplay('application', false);
/*
//Show the section
var section = $$('span[tab_caption_raw="Application"]')[0].select('span[id*=section.]')[0];
section.show();
//Show the tab
$$('.tab_caption_text').each(function(caption) {
if (caption.innerHTML == 'Application') {
caption.up('.tab_header').show();
}
});
*/
}
for false code block use
function onCondition() {
g_form.setSectionDisplay('application', true);
/*
//Hide the section
var section = $$('span[tab_caption_raw="Application"]')[0].select('span[id*=section.]')[0];
section.hide();
//Hide the tab
$$('.tab_caption_text').each(function(caption) {
if (caption.innerHTML == 'Application') {
caption.up('.tab_header').hide();
}
});
*/
}
Vinod Kumar Kachineni
Community Rising Star 2022
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2019 11:28 AM
Hi,
I have created Class field with choice "Application" , "Business Service" and "Discovered Service" in the table.
and similarly created three section i.e. "Application" ,"Business Service" and "Discovered Service" .
i want to show section on the bases of class ..
i mean if Application is selected on the Class field then Application section is visible other section must be hide..
when form is loading then all section is hide ...
Client Script : on change
field name : Class
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading) {
g_form.setSectionDisplay('application',false);
g_form.setSectionDisplay('business_service',false);
g_form.setSectionDisplay('discovered_service',false);
return;
}
alert(newValue);
if(newValue == '')
{
g_form.setSectionDisplay('application',false);
g_form.setSectionDisplay('business_service',false);
g_form.setSectionDisplay('discovered_service',false);
}
if(newValue == 'Application')
{
g_form.setSectionDisplay('business_service',false);
g_form.setSectionDisplay('discovered_service',false);
g_form.setSectionDisplay('application',true);
}
if(newValue == 'Business Service')
{
g_form.setSectionDisplay('application',false);
g_form.setSectionDisplay('discovered_service',false);
g_form.setSectionDisplay('business_service',true);
}
if(newValue == 'Discovered Service')
{
g_form.setSectionDisplay('application',false);
g_form.setSectionDisplay('business_service',false);
g_form.setSectionDisplay('discovered_service',true);
}
//Type appropriate comment here, and begin script below
}
Please mark correct if it will be helpful for you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2019 11:33 AM
Check if the Isolate check box is active on UI policy record, this might be the issue.
If this field is not visible configure form layout and bring this on to the record.
https://community.servicenow.com/community?id=community_blog&sys_id=c5c46364dbba6b007d3e02d5ca9619cb
Please mark my response as correct and helpful if it helped solved your question.
-Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2019 11:55 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2019 12:12 PM
Take a look at this.
Please mark my response as correct and helpful if it helped solved your question.
-Thanks