How to show certain section in a form post save of record.

sreeshsurendran
Tera Guru

The requirement is to show certain section in a form post save of record ServiceNow. Not sure how this can be done, I tried via onLoad Client script but seems this is the wrong approach.

 

Any help would be greateful.

 

Thanks,

Sreesh

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@sreeshsurendran 

you can check if record is new and if not then show the section using this syntax

function onLoad() {
	// hide it
    g_form.setSectionDisplay('section_name', false);
    if (!g_form.isNewRecord()) {
		// show it if it's an existing record
        g_form.setSectionDisplay('section_name', true);
    }
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

6 REPLIES 6

Debasis Pati
Tera Guru

Hello @sreeshsurendran ,

I have taken here example of closure information section,
You can modify it according to your section

Use the below in client script 
g_form.setSectionDisplay('closure_information',false);

Please mark it as correct if this helps you.

Regards,
Debasis


Hello @sreeshsurendran ,

You can write on load script or on change depending on your selection and you can check
for example if my state is closed then only i want to show the closure information tab then the foloowing will help

if(g_form.getValue('state')=='7'){
g_form.setSectionDisplay('closure_information',false);
}

like the above you can build your own condition this will help you.

Please mark it as correct if this resolves your issue.

Regards,
Debasis

Rohit  Singh
Mega Sage

hi @sreeshsurendran , Form sections can be configured using Form Design. You can add or remove a form section or you can also add or remove fields of any section. 

 

In below snip see various section of an incident record highlighted in Green.

 

RohitSingh3_0-1740548218885.png

 

If my response helped, please mark it correct and close the thread so that it benefits future readers.

 

Regards,

Rohit

Ankur Bawiskar
Tera Patron
Tera Patron

@sreeshsurendran 

you can check if record is new and if not then show the section using this syntax

function onLoad() {
	// hide it
    g_form.setSectionDisplay('section_name', false);
    if (!g_form.isNewRecord()) {
		// show it if it's an existing record
        g_form.setSectionDisplay('section_name', true);
    }
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader