Is there a easy way to revert a form variable back to its default value? I currently do the following, but it seems a little excessive and hackish using an eval()…
var frm_tracking_number = null;
if (some_condition_im_testing_for == false) {
var myForm = solutionModel.getForm(currentcontroller.getName());
var fvariable_frm_tracking_number = myForm.getFormVariable("frm_tracking_number");
currentcontroller.setDataProviderValue(fvariable_frm_tracking_number.name, eval(fvariable_frm_tracking_number.defaultValue));
}
The eval() is needed because .defaultValue will return a string and thats no good for cases where the default value is something more complex than a number or string, like null in this case.
P.S. Yes, I am fully aware I could just do frm_tracking_number = null in my if() block, but it has much less load on my brain to only have to keep track of one spot (where the var is defined) for each form variable’s default value if I need to change it.