I have a radio button that is defined as follows:
a!radioButtonField( label: "", labelPosition: ri!labelPosition, choiceLabels: { "kg", "lbs" }, choiceValues: { 1, 0 }, value: ri!weightUnit, saveInto: { ri!weightUnit, a!save( local!BMI, rule!INS_RULE_BMICalculator( height: ri!height, weight: ri!weight, heightUnit: ri!heightUnit, weightUnit: ri!weightUnit ) ) }, showWhen: not( ri!readOnly ), choiceLayout: ri!choiceLayout )
When I change the value from kg to lbs, the value of local!BMI is updated. But, when I switch back to kg, it's not updated, when it should be. I've tried testing the INS_RULE_BMICalculator with the values stored in the rule inputs, and it works fine. Does anyone have any ideas as to what I could do differently to get the local!BMI variable to update any time the value of this radio button field is changed?
Discussion posts and replies are publicly visible
Hi jwithingtonedwards,
Can you share the expression inside this rule INS_RULE_BMICalculator, please? any chance you are using load() inside this rule INS_RULE_BMICalculator?
May be either something is wrong is the inner expression rule INS_RULE_BMICalculator or it can be that rule is configured in load. Can you please check these.
I know this sounds crazy, but would it be possible to refactor the choice values to be 1 and 2 instead of 1 and 0. I'm wondering if there's something casting the choiceValue as boolean and evaluating whether it's true.
Hello - In case you are using load() inside the rule INS_RULE_BMICalculator please change it to with() or a!localVariables. It might resolve your issue. In case you're not using load() inside this rule, can you please share the contents of this rule so that it will help in resolving this issue of yours.
rajeshm said:any chance you are using load()
This is my first guess as well. Several years ago I spent about 5 hours debugging a form that experienced this exact behavior when setting some lower values with an expression rule that used load() instead of with(). Luckily now a!localVariables() handles this issue by default without even needing to use the advanced a!refreshVariable() settings.
Yes, thanks for your help. I switched it to with()