Unable to hide the section on form

rameshrv999
Giga Contributor

Hi All,

I am trying to hide the Configuration section on cmdb_ci_solaris_server table through client script, the actual problem I am facing hear is two sections are there with Configuration name for two different views one is for Default view another is for Compliance.

When I ran that script Default view section is hidden but Compliance one is not hiding please I believe that names for sections are different but I am not find the names, please let me know how can we fix this issue.

8 REPLIES 8

Chuck Tomasi
Tera Patron

Can you share the script you are using and any other details of the client script record?


Hello,


I'm looking do to basically the same thing, hide form sections based on the current view.


Currently we are working on the 'Default view' and the client script works fine to hide the sections. Here is the script:


------------------------------------------------------------------------------------------------------------------



function onLoad() {



var sections = g_form.getSections();



//Reçue ou en triage


var state = g_form.getValue('state');


if( state == 10 ) {


sections[4].style.display = 'none';   //P1 - Ouverture


sections[5].style.display = 'none';   //P1 - Besoins / Solutions


sections[6].style.display = 'none';   //P1 - Bénéfices


sections[7].style.display = 'none';   //P1 - Stratégies


sections[8].style.display = 'none';   //P1 - Processus d'affaires


sections[9].style.display = 'none';   //P1 - Budget


g_form.hideRelatedLists();



}


}



------------------------------------------------------------------------------------------------------------------



We created a new view and want to hide different form sections specific to that view.



I did some tests and looks like the script only applies to the default view.



How can we include the code to check the view ?



Thank you


If your sections are different between different views, you need to write a separate client script for each view.



Uncheck the Global checkbox and fill in the view name for that specific client script.


find_real_file.png



FWIW, I recommend using g_form.setSectionDisplay() instead of setting style.display manually.



https://developer.servicenow.com/app.do#!/api_doc?v=jakarta&id=r_GlideFormGetSections


Works great now for the part of hiding the form sections.



However I have a weird behavior for one specific custom view for which the 'g_form.getValue('state')' in the code returns a 'blank' value. If I execute the same script for another custom view (and same table) the state value is returned.



Result of the 'blank' state value in an alert.



find_real_file.png



Guess I'll open a ticket on HI for this.