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 / SetValue does not chan...
Power Apps
Unanswered

SetValue does not change text in "Yes/No" Choice column

(1) ShareShare
ReportReport
Posted on by 4
I am trying to change the value of a "Yes/No" choice column using JavaScript in a model driven app.
 
If the user selects "Yes" in the form field, I am checking if other fields have a value.
If some do not have values, I need to change the form field the user changed back to "No"
 
I am using setValue to do this:
formContext.getAttribute('asp_railcarisgone').setValue(false);
 
This is technically working, the value of the field is set to false but the text in the field stays "Yes"
 
I need the text to change to "No"
 
How do I do that?
 
I have the same question (1)
  • ITWithAllan Profile Picture
    160 Moderator on at

    In a model-driven app, when you update a Yes/No choice column using setValue(false), sometimes the UI does not refresh immediately. To ensure the text updates properly, follow these steps:

    Solution:

    After setting the value, fire the OnChange event and refresh the control:

     
    formContext.getAttribute('asp_railcarisgone').setValue(false);
    formContext.getAttribute('asp_railcarisgone').fireOnChange(); // Trigger the change event
    formContext.getControl('asp_railcarisgone').refresh(); // Refresh the UI

    Why this works:


    1. setValue(false): Updates the value in the background.

    2. fireOnChange(): Ensures any event handlers tied to the field (like business rules) execute.

    3. refresh(): Forces the UI to reflect the change.
       

    This should make the field visually update to "No" when you set it to false. 🚀

  • JN-27032010-0 Profile Picture
    4 on at
     
    Thank you for the quick reply.
    and thank you for turning me onto refresh :)
     
    It looks like formContext.getAttribute('asp_railcarisgone').refresh() is not a function.
    but formContext.data.refresh() is.
     
    Unfortunately, that does not work.
    I don't understand why though, from the documentation it says it "Asynchronously refreshes and optionally saves all the data of the form without reloading the page" but that is clearly not happening.
     
    If I use a success callback function on the data refresh, it says it is successful, but my field still says ""Yes"
     
    Here is what I am using:
     
    formContext.getAttribute('asp_railcarisgone').setValue(false);
    formContext.getAttribute('asp_railcarisgone').fireOnChange();  <-- I don't think this is needed though since all it does is call the onchange event which is the function we are currently in.
    formContext.data.refresh();
  • ITWithAllan Profile Picture
    160 Moderator on at
    Try using the number value of false like:

    formContext.getAttribute('asp_railcarisgone').setValue(0);

    Maybe this will work, but lets keep on trying to solve that!

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 493 Most Valuable Professional

#2
11manish Profile Picture

11manish 479

#3
Haque Profile Picture

Haque 328

Last 30 days Overall leaderboard