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

Hi Lina,

did you try UI Policy for that ??


***Mark Correct or Helpful if it helps.***

Hi Lina,

this seems to be working try and see if it works or if it doesn't let us know.

if (oldValue=='false' && newValue=='true'){
		location.reload();
	}

 

Mark Correct or Helpful if it helps.


***Mark Correct or Helpful if it helps.***

This is what I was calling out @Yousaf, but the concept is lost

Best Regards
Aman Kumar

Hi @Lina

Try this;

if (oldValue=='no' && newValue=='yes'){
		location.reload();
	}

 

Let me know if you need help, and discourage marking copied responses as helpful or correct

Best Regards
Aman Kumar

Hi,

Please refer below snippet, I have added this script, but its not working.

We have to check if value is "No" then rest all field will disabled. and if "No" changes to "Yes" then only form should reload.

If at first time "Yes" is selected then nothing should happen, all will work as per the flow.

Here in if block I am using  (newValue == 'No') condition and in else if block (oldValue == 'No' && newValue == 'Yes'). Because of this its conflicting?

Only if block is executing as expected here.(for "no" condition to disable fields)

 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
    if (newValue == 'No') {     
        g_form.showErrorBox("working_employee", "Policy approval is not required. Please submit the form to close the request and contact Federal.Request@accfederal.com.");
        
        //To disable fileds when when answr is "No". 
        g_form.setMandatory('eid', false);
        g_form.setReadOnly('eid', true);
        g_form.setMandatory('emp_name', false);
        g_form.setReadOnly('emp_name', true);
        g_form.setMandatory('act', false);
        g_form.setReadOnly('act', true);
        g_form.setMandatory('compny_type', false);
        g_form.setReadOnly('compny_type', true);

    } else if (oldValue == 'No' && newValue == 'Yes') {
        location.relaod();
    }
}