Reload a form when field value changes from No to Yes.

Lina5
Tera Contributor

Hi,

We have a requirement where we need to make rest other fields disabled when in particular field(Yes/No field) value is selected as "No". Written a onChange client script for this which is working.

Here we need to Reload the form when user changes the value from "No" to "Yes". Can I know which script should be added for this.

note: when "Yes" is selected initially form should work normally.(no need to disable fields /reload form)

 

Thanks in advance!

 

12 REPLIES 12

To check the conflict, add alert in your if else condition just before reload statement to check whether its working or not

Best Regards
Aman Kumar

Got the solution..

It does not return oldValue, which we have set as No.

Just got to know oldValue is nothing but the value of the field when the form loaded and prior to the change.

So we created one variable(reload_form) which will be hidden on form. And have set value as 'No'. 

g_form.setValue('reload_form', 'No');

And added below if condition.

if (g_form.getValue('reload_form') == "No" && newValue == 'Yes'  ) {
       location.reload(); 
    }

Its working as expected, when value selected as No, then changes to yes, then only form will reload.

If at the first time only value is selected as 'Yes' then form won't reload.

Great @Lina

If your issue is resolved,
Feel free to mark correct, if your issue has been resolved, so it ends up in solved queue.

Will be helpful for others looking for the similar query.

Best Regards
Aman Kumar