Validations button specific
I have a scenario where, if I click the "Reject" button, the comments field should be required and cannot be empty. If the "Approve" button is clicked, the comments field should be optional and be submitted. I have a ri!cancel input that changes to true when "Reject" is clicked and false when "Approve" is clicked. However, the validation isn't working as expected. I tried setting the "required" parameter to ri!cancel, but after clicking "Reject" and then "Approve," ri!cancel doesn't seem to change back to false, and still throws validation for approve button if comments is empty
Code for the interface comment field and buttons: a!textField(
label: "Comments",
labelPosition: if(ri!readOnly, "ADJACENT", "ABOVE"),
value: ri!TR_Expense_Details.comments,
saveInto: ri!TR_Expense_Details.comments,
characterLimit: 250,
showWhen: ri!TR_Expense_Details.hrApproval = true(),
required: ri!cancel,
readOnly: not(a!defaultValue(ri!readOnly, true())),
validations: if(
and(
isnull(ri!TR_Expense_Details.comments),
ri!cancel
),
"Comment is mandatory when rejecting",
{}
)
)
buttons: a!buttonLayout(
primaryButtons: {
a!buttonWidget(
label: if(
ri!TR_Expense_Details.hrApproval,
"Approve",
"Submit"
),
/*value: false(),*/
saveInto: {
a!save(ri!cancel,false()),
a!save(ri!TR_Expense_Details.dateLogged, now()),
a!save(
ri!TR_Expense_Details.hrApproval,
true()
)
},
submit: true,
style: "SOLID"
)
},
secondaryButtons: {
a!buttonWidget(
label: if(
ri!TR_Expense_Details.hrApproval,
"Reject",
"Cancel"
),
value: true,
saveInto: {
ri!cancel,
a!save(ri!TR_Expense_Details.dateLogged, now())
},
submit: true,
style: if(
ri!TR_Expense_Details.hrApproval,
"GHOST",
"OUTLINE"
),
color: if(
ri!TR_Expense_Details.hrApproval,
"NEGATIVE",
null()
),
validate: false
)
}
)
