How to show/hide section when click on button?

shrinivasprasad
Tera Expert

Hi All,

The section of the requested form will be visible when click on button any one please help

please send code for it.

Thanks in advance.

Thanks,

Shrinivasprasad 

1 ACCEPTED SOLUTION

Alok Das
Tera Guru

Hi Shrinivasprasad,

You should check the client(checkbox) true in ui action and mention the unique function name in the onclick field as: setsectiondisplay();

and write the code as below:

function setsectiondisplay(){
	g_form.setSectionDisplay('test',false);
}

Replace the 'test' with the section name

Make sure section name of your section, should be completely lower-case. Sections including spaces should use an underscore in place of the first space with the rest of the spaces removed.

Hope this will resolve your issue.

 

Kindly mark correct/helpful based on the impact.

 

Regards,

Alok

View solution in original post

5 REPLIES 5

Omkar Mone
Mega Sage

Hi 

Where are we doing this?

 

If not portal then you can try this code in Ui Action.

 

var sections = g_form.getSections();  

sections[4].style.display = 'none';

 

Regards,

Omkar Mone.

www.dxsherpa.com

Hi Omkar,

Thanks for quick response,

This code is not working

i took planning as a button i want to perform that action.

Thanks

VigneshMC
Mega Sage

Refer below link 

https://www.servicenowguru.com/scripting/client-scripts-scripting/showhide-form-section/

Use these scripts in ui action in client side and run it on click

Alok Das
Tera Guru

Hi Shrinivasprasad,

You should check the client(checkbox) true in ui action and mention the unique function name in the onclick field as: setsectiondisplay();

and write the code as below:

function setsectiondisplay(){
	g_form.setSectionDisplay('test',false);
}

Replace the 'test' with the section name

Make sure section name of your section, should be completely lower-case. Sections including spaces should use an underscore in place of the first space with the rest of the spaces removed.

Hope this will resolve your issue.

 

Kindly mark correct/helpful based on the impact.

 

Regards,

Alok