web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Model-Driven app, Clea...
Power Apps
Answered

Model-Driven app, Clear field when another field changes?

(0) ShareShare
ReportReport
Posted on by 782
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);
}
 
Categories:
  • Verified answer
    notj Profile Picture
    782 on at
    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.");
        }
    }
     
     

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.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 221 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 188 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 120

Last 30 days Overall leaderboard