The CreatorCon Call for Content is officially open! Get started here.

How can I show a tab/section on a form ONLY when in a certain state?

cicgordy
Tera Guru

Hi all,

 

I need to show a tab/section below called "business analysis" with all the fields in it, on the change form, ONLY when the state is "implement" and ONLY when the close code(closure information) is "successful" or "successful with issues".

 

cicgordy_0-1676822074141.png

"business analysis" tab/section is located next to the closure information section.

 

Can anyone help with the script? Thanks

1 ACCEPTED SOLUTION

@cicgordy  I am sharing below working and tested code and please try with UI policy  as client script might be required multiple to achieve same, so here would be UI policy as best option.

 

Create a UI Policy with condition state=implement and closure code is one of "successful" or "successful with issues". -> save UI policy -> click on script tab -> paste in Execute if True g_form.setSectionDisplay('business_analysis',false); -> paste in Execute if false g_form.setSectionDisplay('business_analysis',true);

 

Imp: tab section name convention is considered as, example if tab section name is 'Related Records' , then you have take 'related_records' in your code.

 

Example i have tried as i dont have business_analysis section tab, so i have considered different one 'related records' for section tab and selected any random value to share with you:

1. created UI policy:

AbhayKumar1_0-1676866697950.png

2. used script to hide section tab:

AbhayKumar1_1-1676866759767.png

 

Hope this will help you.

View solution in original post

6 REPLIES 6

Abhay Kumar1
Giga Sage

@cicgordy you can try below in client script on-load,

if(g_form.getDisplayValue("state")== 'insert value of implement' && g_form.getDisplayValue('closure_code')=='inset value of successful')

{

g_form.setSectionDisplay('insert name of section', true);

}

Hope this will help you.

cicgordy
Tera Guru

Hi @Abhay Kumar1 thanks for your reply.

Sadly I did as you suggested but isn't working. The section doesn't hide in other states different from "implement", it shows in all states. Section should be visible only within implement state when "close code"  choice selected is one of "successful" or "successful with issues".

@cicgordy  I am sharing below working and tested code and please try with UI policy  as client script might be required multiple to achieve same, so here would be UI policy as best option.

 

Create a UI Policy with condition state=implement and closure code is one of "successful" or "successful with issues". -> save UI policy -> click on script tab -> paste in Execute if True g_form.setSectionDisplay('business_analysis',false); -> paste in Execute if false g_form.setSectionDisplay('business_analysis',true);

 

Imp: tab section name convention is considered as, example if tab section name is 'Related Records' , then you have take 'related_records' in your code.

 

Example i have tried as i dont have business_analysis section tab, so i have considered different one 'related records' for section tab and selected any random value to share with you:

1. created UI policy:

AbhayKumar1_0-1676866697950.png

2. used script to hide section tab:

AbhayKumar1_1-1676866759767.png

 

Hope this will help you.

That worked, many thanks!!