Skip to main content
September 8, 2022
Question

Display the Field, based on user selection by Radiobutton.!

  • September 8, 2022
  • 3 replies
  • 1 view

a!radioButtonField(
label: "Status",
choiceLabels:{"APPROVE","REJECT","RETURN"},
choiceValues: :{"APPROVE","REJECT","RETURN"} ),

a!paragraphField( 
showwhen(...)

)

*if user selects Reject or Return, then only show the Paragraph field.

3 replies

harshitb6843
September 8, 2022

What is your question here? If it is about how you do it, then you must be saving the radio button selection somewhere. You can just use that variable to compare it with the needed value in front of showWhen. 

September 8, 2022

hi, I think this will help you. Create two rule inputs as value and paravalue.

{
a!radioButtonField(
label: "Status",
labelPosition: "ABOVE",
choiceLabels: {"APPROVE","REJECT","RETURN"},
choiceValues: {"APPROVE","REJECT","RETURN"},
value: ri!value,
saveInto: {ri!value},
choiceLayout: "STACKED",
validations: {}
),
a!paragraphField(
label: "Paragraph",
labelPosition: "ABOVE",
value: ri!paravalue,
saveInto: {ri!paravalue},
refreshAfter: "UNFOCUS",
height: "MEDIUM",
validations: {},
showWhen: or(ri!value="REJECT",ri!value="RETURN")
)

}

Thanks.

mikes0011
Brainy
September 8, 2022

"ShowWhen" requires a boolean value (or null, which almost always evaluates as "true" by default).  You can pass literally any boolean or "expression that evaluates as a boolean" to a ShowWhen parameter. 

Beyond this, I typically recommend developers actually establish a local variable that will evaluate the logic and store the resulting boolean itself, as this functional abstraction helps with code readability and cuts way down on repetitive logic when similar code is needed elsewhere on a form (like if you had 4 or 5 fields all relying on the same condition for display, etc).

The Expression Guru