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

Community site session details

Session Id : Q0pOG88T95yBclbrq6MwUG
Power Apps - Power Apps Pro Dev & ISV
Unanswered

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

Like (1) ShareShare
ReportReport
Posted on 27 Mar 2025 20:42:03 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 (0)
  • AllanMouraDev Profile Picture
    139 Super User 2025 Season 2 on 28 Mar 2025 at 18:30:43
    SetValue does not change text in "Yes/No" Choice column
    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!
  • JN-27032010-0 Profile Picture
    4 on 28 Mar 2025 at 14:59:11
    SetValue does not change text in "Yes/No" Choice column
     
    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();
  • AllanMouraDev Profile Picture
    139 Super User 2025 Season 2 on 27 Mar 2025 at 22:54:10
    SetValue does not change text in "Yes/No" Choice column

    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. 🚀

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Telen Wang – Community Spotlight

We are honored to recognize Telen Wang as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 688 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 499 Super User 2025 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 410 Super User 2025 Season 2

Last 30 days Overall leaderboard
Loading started