How To Hide A Category From The Service Catalog From Specific Users Servicenow
Prove/Hibernate Course Department by Name
The start parameter is only the name of your section, which should exist completely lower-example. Sections including spaces should use an underscore in place of the first space with the rest of the spaces removed. For example, a form department with a label of 'Schedule and Planning' would require a parameter of 'schedule_andplanning'. The 2nd parameter is a true/faux boolean that indicates whether the form section should be visible or not.
F
orm sections are a dandy way to segment information on a course into pieces that make sense to be grouped together. The most mutual example of the employ of course sections is the 'Comprehensive Alter' course. If you want to learn more well-nigh how forms, form sections, and views work I HIGHLY recommend a postal service I wrote a while ago on the topic. When customers employ form sections, the need frequently arises to be able to bear witness and hide that form section with a customer script onLoad or on some changed field trigger.
People take known how to hide these form sections based on an ID number (which corresponded to the gild of the form sections on the form). This method works fine, only it fails every bit soon as y'all add a new course section or change the ordering of your course sections in some mode. Considering of this, there has long been a need to hide form sections based on the section name or caption. Nobody has been able to figure out a mode to exercise this…until at present. Read on for the details…
First, for reference purposes, I'll show you lot the standard, number-based script for hiding form sections.
Hibernate a course department…
If I wanted to hide the 2d form department on my course I could apply this script…
sections[ ane ].style.display = 'none' ;
Testify a form section…
If I wanted to show the second form section on my form I could utilise this script…
sections[ ane ].style.brandish = 'block' ;
The start parameter is simply the proper noun of your section, which should be completely lower-instance. Sections including spaces should use an underscore in identify of the first infinite with the rest of the spaces removed. For example, a form section with a label of 'Schedule and Planning' would require a parameter of 'schedule_and_planning'. The second parameter is a true/false boolean that indicates whether the form section should be visible or not.
The method for hiding a form section by name is really simply a slight alter to the way that the form department is selected. Whereas the number-based method returns all form sections in an array, the proper noun-based method selects just that specific form section based on the form department explanation. This method utilizes Prototype selectors to target the specific span that the form section resides in based on the 'tab_caption' attribute, but the result is the same.
Hide a course section by name…
If I wanted to hibernate the course department with a name of 'Schedule' I could use this script. Only replace 'Schedule' with the proper name of your form section to use it in your environment.
var section = $$( 'span[tab_caption_raw="Schedule"]' ) [ 0 ].select ( 'span[id*=section.]' ) [ 0 ] ;
section.hide ( ) ;
//Hide the tab
$$( '.tab_caption_text' ).each ( function (explanation) {
if (caption.innerHTML == 'Schedule' ) {
caption.up ( '.tab_header' ).hide ( ) ;
}
} ) ;
Show a form department by proper name…
If I wanted to show the course section with a proper noun of 'Schedule' I could use this script. Just supervene upon 'Schedule' with the name of your form section to apply it in your environment.
var section = $$( 'span[tab_caption_raw="Schedule"]' ) [ 0 ].select ( 'bridge[id*=department.]' ) [ 0 ] ;
section.prove ( ) ;
//Prove the tab
$$( '.tab_caption_text' ).each ( function (explanation) {
if (caption.innerHTML == 'Schedule' ) {
caption.up ( '.tab_header' ).bear witness ( ) ;
}
} ) ;
Automatically selecting the shown grade section
In some cases you might desire to automatically select the course section tab as it is shown. You can too practise this through client scripting. I've documented that solution here.
Desire to learn more nearly controlling the beliefs of tabs and form sections in ServiceNow? Check out these other manufactures for more than data!
Share This Story, Cull Your Platform!
How To Hide A Category From The Service Catalog From Specific Users Servicenow,
Source: https://servicenowguru.com/scripting/client-scripts-scripting/showhide-form-section/
Posted by: orvisbrimee.blogspot.com
0 Response to "How To Hide A Category From The Service Catalog From Specific Users Servicenow"
Post a Comment