I feel like this should be pretty simple but I'm failing to accomplish it. I have a field named Payor and one named Payor Type. When my Payor Type field changes, I want to clear out any value in the Payor field.
I would love to do this OOB instead of through code but I'm not seeing the option to do so. Please correct me if I'm wrong there.
Here's my JS function that I'm trying to use. I'm not great with JS so I'm sure there's something wrong here.
function clearPayorField(executionContext) {
var formContext = executionContext.getFormContext();
formContext.getAttribute("appdev_payor").setValue(null);
}
OK, I finally got it. Most of the things I came across said use the logical name, this was incorrect. Using Schema name and updated code below resolved it. Hopefully someone in the future finds this early in their search instead of two days later like me.
function clearPayorField(executionContext) {
var formContext = executionContext.getFormContext();
var payorField = formContext.getAttribute("appdev_Payor"); // Replace "appdev_Payor" with the actual Schema name of your field
if (payorField) {
payorField.setValue(null);
console.log("Payor field cleared successfully.");
} else {
console.error("Error: Payor field is null or undefined. Please check the schema name.");
}
}
1 people found this reply helpful.
Was this reply helpful?YesNo
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.