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 / Patch a record variabl...
Power Apps
Unanswered

Patch a record variable not working

(1) ShareShare
ReportReport
Posted on by 160
I have a task form and if the user answers "No" to Action Required I want to set the estimated hours used to 0 (zero).  In the OnChange of cboTaskActionRequired I have the following Fx. It does not give an error, but it does not change the underlying variable. The underlying variable is varEditTask and it is just a record, not a table of data.
 
I have the Notify action just to confirm the OnChange is firing which it is.
 
Notify("Change Triggered",NotificationType.Information,4000);
Patch(varEditTask,
        {
            'Estimated Hours':0
        }
);
 
 
 
Categories:
I have the same question (0)
  • Pstork1 Profile Picture
    69,556 Most Valuable Professional on at
    What generates the underlying variable?  It may be that the variable is changing but a later OnSelect is overriding it with a default value.

    ----------------------------------------------------------------------------------
    If this Post helped you, please click "Does this answer your question" and give it a like to help others in the community find the answer too!

    Paul Papanek Stork, MVP
    Blog: https://www.dontpapanic.com/blog
     
  • FW-07051511-0 Profile Picture
    160 on at
    @Pstork1 It is being set for a gallery ThisItem
  • timl Profile Picture
    37,214 Super User 2026 Season 1 on at
     
    With the use of Patch where you don't specify a data source as the first argument, Patch won't update the variable. 
     
    With all usages of Patch, it returns the record that was changed/updated.
     
    If you reset the variable by calling Set, that should hopefully resolve the issue.
     
    Notify("Change Triggered",NotificationType.Information,4000);
    Set(varEditTask,
        Patch(varEditTask,
             {
                  'Estimated Hours':0
             }
       )
    );
     
  • FW-07051511-0 Profile Picture
    160 on at
    @timl I've tried your suggestion, it doesn't error but the 0 (zero) value does not show up in the estimated hours control even though I have incorporated a 
    Reset(inpTaskEstHours) In the OnChange Fx. Additionally, the overall Patch for the record has an error now which says it cannot find "Estimated Hours". I've checked the new varEditTask and estimated hours is zero, as desired, but it seems to have broken things down stream.
     
     
     
    Notify("Change Triggered",NotificationType.Information,4000);
    Set(varEditTask,
        Patch(varEditTask,
            {
                'Estimated Hours':0
            }
        )
    );
    Reset(inpTaskEstHours);
     
  • timl Profile Picture
    37,214 Super User 2026 Season 1 on at
     
    You mention that varEditTask is originally set to ThisItem on a gallery.
     
    I suspect 'Estimated Hours' isn't shown on the gallery, which would result in the field/value not being persisted in the variable. 
     
    That would be one reason for the very confusing error 'Estimated Hours’ does not exist, the column with the most similar name is ‘Estimated Hours’.
  • FW-07051511-0 Profile Picture
    160 on at
    @timl
     
    I change to Set(varEditSet, LookUp('Tasks', ID=ThisItem.ID)) and it made no difference. Same error and nothing showing in estimated hours.
  • Pstork1 Profile Picture
    69,556 Most Valuable Professional on at
    @FW-07051511-0 Can you show how you are using varEditTask in your App? Setting the variable won't be reflected in the Gallery or in your Data unless you are applying it in some way, like having the default value of a control set to varEditTask.Value or something like that.

    ----------------------------------------------------------------------------------
    If this Post helped you, please click "Does this answer your question" and give it a like to help others in the community find the answer too!

    Paul Papanek Stork, MVP
    Blog: https://www.dontpapanic.com/blog
     
  • FW-07051511-0 Profile Picture
    160 on at
     
    I am doing just what you suggest. Each of my controls have
     
    cboStatus DefaultSelectedItems = varEditTask.Status
    inpEstHrs Default = varEditTask.'Estimated Hours'
    inpTaskID Default = varEditTask.ID
    inpTaskSubject Default = varEditTask.Subject
     
     
    And so on.
     
    Point of note, I am using all modern controls.
  • timl Profile Picture
    37,214 Super User 2026 Season 1 on at
     
    With regards to your previous message, I'm not sure if this is a typo, but this should be varEditTask rather than varEditSet.
     
    >>I change to Set(varEditSet, LookUp('Tasks', ID=ThisItem.ID)) and it made no difference. 
     
    If it's not a typo, could you try setting varEditTask to see if that makes a difference?
     
    Set(varEditTask, LookUp('Tasks', ID=ThisItem.ID)) 
     
  • FW-07051511-0 Profile Picture
    160 on at
     
    Yes that was a typo just in this discussion. And I've tried you recommendation around LookUp and it made no difference.
     
     

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 Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 424

#2
WarrenBelz Profile Picture

WarrenBelz 355 Most Valuable Professional

#3
11manish Profile Picture

11manish 290

Last 30 days Overall leaderboard