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 not updating sha...
Power Apps
Answered

Patch not updating sharepoint

(0) ShareShare
ReportReport
Posted on by 104

Hi, I've been trying to write to a collection (UserData) and then patch updates from the collection to SP. I succeed in creating the record, but my attempts to update it further all fail, no matter how creative I get with the coding.

 

My initial attempts evaluating IsBlank to create a new record or update an existing one resulted in a new record being created for each update, despite my formula including a lookup in the patch so that the correct record should be updated. The same happened when I tried rewriting it to use the Coalesce function.

 

I've tried to rewrite it so that it uses an entirely different formula to handle updates instead, but none of the updates appear to be being written to the datasource, despite being correctly patched to the collection from the various controls.

 

I'm forced to include the With function, or else it cannot identify the columns ProjectName, etc. I tried a variation omitting the With and patching the updates as Title:varTodaysTimes.ProjectName, but again the updates weren't patched.

 

 

 

If(varTodaysTimes.Update = true,
 With(varTodaysTimes,
 Patch(TimeSheet,
 LookUp(TimeSheet, ID = SharePointID),
 {
 Title:ProjectName,
 EmployeeName:EmployeeName,
 Date:Date,
 StartTime:StartTime,
 StartWork:StartWork,
 BreakStart:BreakStart,
 BreakEnd:BreakEnd,
 EndWork:EndWork,
 EndTime:EndTime,
 ActiveSession:ActiveSession
 }
 );
 Patch(UserData, varTodaysTimes,
 {Update:false}
 )
)
);

 

 

 

Each control has a separate patch that writes Now() to the collection UserData and updates the column Update to true. The above patch should then write the same info from the collection to the datasource. 

  

If anyone can shed any light on what I'm missing (or point me in the right direction if I'm completely off the mark!), I'd be eternally grateful 🙂

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    156,275 Most Valuable Professional on at

    Hi @teespolyglot ,

    Firstly, only one of the below may be correct as I do not know what you are aligning the collection to. Also note the syntax of the With() statement needs to set a value with it (it is essentially a temporary variable / collection) and you can only use it in one action.

    If(
     varTodaysTimes.Update,
     With(
     {wTimes:varTodaysTimes},
     Patch(
     TimeSheet,
     {ID:SharePointID),
     {
     Title:wTimes.ProjectName,
     EmployeeName:wTimes.EmployeeName,
     Date:wTimes.Date,
     StartTime:wTimes.StartTime,
     StartWork:wTimes.StartWork,
     BreakStart:wTimes.BreakStart,
     BreakEnd:wTimes.BreakEnd,
     EndWork:wTimes.EndWork,
     EndTime:wTimes.EndTime,
     ActiveSession:wTimes.ActiveSession
     }
     )
     )
    );
    If(
     varTodaysTimes.Update,
     ForAll(
     varTodaysTimes As aPatch,
     Patch(
     UserData, 
     {ID:aPatch.ID}
     {Update:false}
     )
     )
    );

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

     

  • teespolyglot Profile Picture
    104 on at

    Thanks for your reply and help Warren. I've tried using the formula you suggested but I am still encountering the same problem (I think I may have already tried a similar tactic by using {Title:varTodaysTimes.ProjectName} etc.

     

    My app has a button that patches to a collection, using Set(varTodaysTimes, Patch(UserData, ...

     

    On the second screen, there are multiple buttons, each with the function Patch(UserData, varTodaysTimes, {StartWork: Now(), Update: true})

     

    I then have a timer pinging for a connection with the below formula (I overwrote my initial formula for Defaults using your formula in the hope it would resolve my issue, but alas it still remains). Each time I patch a new time to the UserData, varTodaysTimes record, it creates a new entry in SharePoint as if the Defaults value has been passed through, instead of it recognising and updating the record with the SharePointID.

     

    I've included my full patch to SP formula in the hope that you may be able to identify why this is happening. Your help is massively appreciated! 🙂

     

     

    If(Connection.Connected,
    
    If(varTodaysTimes.New = true,
     With({wTimes:varTodaysTimes},
     Patch(TimeSheet,Defaults(TimeSheet),
     {
     Title:wTimes.ProjectName,
     EmployeeName:wTimes.EmployeeName,
     Date:wTimes.Date,
     StartTime:wTimes.StartTime,
     StartWork:wTimes.StartWork,
     BreakStart:wTimes.BreakStart,
     BreakEnd:wTimes.BreakEnd,
     EndWork:wTimes.EndWork,
     EndTime:wTimes.EndTime,
     ActiveSession:wTimes.ActiveSession
     }));
     Patch(UserData, varTodaysTimes,
     {New:false}));
    
    If(varTodaysTimes.Changed = true,
     With({wTimes:varTodaysTimes},
     Patch(TimeSheet,{ID:wTimes.SharePointID},
     {
     Title:wTimes.ProjectName,
     EmployeeName:wTimes.EmployeeName,
     Date:wTimes.Date,
     StartTime:wTimes.StartTime,
     StartWork:wTimes.StartWork,
     BreakStart:wTimes.BreakStart,
     BreakEnd:wTimes.BreakEnd,
     EndWork:wTimes.EndWork,
     EndTime:wTimes.EndTime,
     ActiveSession:wTimes.ActiveSession
     }));
    Patch(UserData,varTodaysTimes,
     {Changed:false}
     ))
    )

     

  • WarrenBelz Profile Picture
    156,275 Most Valuable Professional on at

    Hi @teespolyglot ,

    So isolating the issue, it is here

    Patch(
     UserData, 
     varTodaysTimes, 
     {
     StartWork: Now(), 
     Update: true
     }
    )

    which is creating a new record instead of updating an existing item? Maybe try

    Patch(
     UserData, 
     {ID:varTodaysTimes.ID}, 
     {
     StartWork: Now(), 
     Update: true
     }
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

  • teespolyglot Profile Picture
    104 on at

    Thanks again for your persistence with this. It's greatly appreciated!

     

    My collection UserData has the ID column renamed to SharePointID, so I tried your method, adapting it to be:

    Patch(UserData,
     {SharePointID:varTodaysTimes.SharePointID},
     {
     StartWork:Now(),
     Update:true
     }
    );

    However, the problem persists and a new record is created each time. I'm utterly perplexed 😞

  • Verified answer
    WarrenBelz Profile Picture
    156,275 Most Valuable Professional on at

    Hi @teespolyglot ,

    Go back to ID if that was the original column name. Assuming varTimes is a Record (not a Table) - which it should be with your code setting it to the result of the Patch, this is very basic code and has to (said cautiously) work if there is a record in UserData with the same ID as varTimes.ID, however you hit on a point with the renaming of the field (not a good idea for a "future you" when coding). Try this (the Collection will have the "new" name whereas SharePoint remembers the original.

    Patch(UserData,
     {ID:varTodaysTimes.SharePointID},
     {
     StartWork:Now(),
     Update:true
     }
    );

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

     

  • teespolyglot Profile Picture
    104 on at

    You hit the nail on the head, as I'm very new to coding PowerApps. It's simple coding and in theory it seems like it should work, but for some reason it doesn't follow my logic. I thank you greatly for your help, but in the end I have abandoned offline use and am patching the values straight to SharePoint.

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 400 Most Valuable Professional

#2
11manish Profile Picture

11manish 141 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 109 Super User 2026 Season 2

Last 30 days Overall leaderboard