Display form section on choice selection otherwise hide

JohnDF
Mega Sage

Hi everyone,

 

I have a requirement that a form section is only display when I select a specific choice in a choice field otherwise the should be hidden.

I created a on change client script but its not working. The section is displayed and when a select "SLIR" choice the section is hidden?? What could be the problem?

 

 

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }

   //Type appropriate comment here, and begin script below
   var select=g_form.getValue('u_themeselection');
	if(select=='SLIR')
		{
   g_form.setSectionDisplay('slir', true);
		}
	else{
		g_form.setSectionDisplay('slir', false);
	}
}

 

 

 

Thanks for your hep.

1 ACCEPTED SOLUTION

You can write 2 client scripts:

  1. OnLoad of form where you can hide the section.
  2. OnChange of choice field where you can check choice value and show the section.

Or you can also have only the OnChange client script if you always want to hide the section even choice value is SLIR

reshmapatil_0-1671077235458.png

 

 

Just one question, do you also want to hide the section on the load of the form even if the choice is "SLIR" in the backend (database)?

 

Regards,

Reshma

**Please mark my answer correct or helpful based on the impact**

View solution in original post

9 REPLIES 9

You can write 2 client scripts:

  1. OnLoad of form where you can hide the section.
  2. OnChange of choice field where you can check choice value and show the section.

Or you can also have only the OnChange client script if you always want to hide the section even choice value is SLIR

reshmapatil_0-1671077235458.png

 

 

Just one question, do you also want to hide the section on the load of the form even if the choice is "SLIR" in the backend (database)?

 

Regards,

Reshma

**Please mark my answer correct or helpful based on the impact**

JohnDF
Mega Sage

Thanks for your reply. I guess you didnt understand me right.

 

The section should be hidden when I load the form, only when I select on the frm the choice "SLIR" in the choice fild than the tab should be visible.

 

Hopefully its now clear.

You can write 2 client scripts:

  1. OnLoad of form where you can hide the section.
  2. OnChange of choice field where you can check choice value and show the section.

 

Just one question, do you also want to hide the section on the load of the form even if the choice is "SLIR" in the backend (database)?

You can also have only the OnChange client script if you always want to hide the section even choice value is SLIR

reshmapatil_0-1671048630200.png

 

Regards,

Reshma

**Please mark my answer correct or helpful based on the impact**

SuhasPSalunkhe
Kilo Guru

I can suggest you some options - 

1. Please create OnLoad client script which always hide your section based on your condition. [To debug please add logs]

2. Please create OnChange UI Policy for your field and please add code in UI Policy script. So that will be very easy for you to track.