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 / Issue: Inconsistent Sh...
Power Apps
Answered

Issue: Inconsistent Sharepoint Updates

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Reposting because somebody marked this as spam. 

I have cached data that I'm writing back to sharepoint.

 

Much of the time some records don't get updated. When PSOCache is refreshed, some of the records revert to their previous value.

 

ForAll(
 PSOCache
 // Update all cached edits back to db
 ,If(Edited
 ,If(IsBlank(ID)
 ,Patch(PSO
 ,Defaults(PSO)
 ,{ MSF: PSOCache[@MSF]
 ,Inspected: PSOCache[@Inspected]
 ,Status: PSOCache[@Status]
 ,Bin: PSOCache[@Bin]
 ,Description: PSOCache[@Description]
 ,OwnerName: PSOCache[@OwnerName]
 ,SN: PSOCache[@SN]
 ,'Vendor Part Number': PSOCache[@'Vendor Part Number']
 ,Ticket: PSOCache[@Ticket]
 ,StatusText: PSOCache[@StatusText]
 ,StatusDetail: PSOCache[@StatusDetail]
 }
 )
 )
 ;UpdateIf(PSO
 ,PSO[@ID]=PSOCache[@ID]
 ,{ MSF: PSOCache[@MSF]
 ,Inspected: PSOCache[@Inspected]
 ,Status: PSOCache[@Status]
 ,Bin: PSOCache[@Bin]
 ,Description: PSOCache[@Description]
 ,OwnerName: PSOCache[@OwnerName]
 ,SN: PSOCache[@SN]
 ,'Vendor Part Number': PSOCache[@'Vendor Part Number']
 ,Ticket: PSOCache[@Ticket]
 ,StatusText: PSOCache[@StatusText]
 ,StatusDetail: PSOCache[@StatusDetail]
 }
 )
 )
 )
 // clear cache
 ;Refresh(PSO)
 ;ClearCollect(PSOCache
 ,AddColumns(
 Filter(PSO
 ,StatusText = "Pending Pickup"
 || StatusText = "Tech Custody"
 ,OwnerName = UserName
 )
 ,"Edited"
 ,false
 ) 
 )

 

 

Categories:
I have the same question (0)
  • Pstork1 Profile Picture
    69,627 Most Valuable Professional on at

    What process are you using to set Edited = "True"?  That's the first place I would look.  I suspect some of the items in your cache aren't being marked as edited so the update isn't firing for those items.  Otherwise the code looks correct.  I would look for something either not setting Edited correctly in the cached record or resetting it to some other state.

  • SoPatt Profile Picture
    Microsoft Employee on at

    It's a good thought but I've already verified Edit is set to true.

     

    Annotation 2019-06-26 161808.jpg

     

    In this case, 3 of the 4 records reverted after the above code executed. On the next try, all 3 of the remaining records reverted. On the third try, all 3 updated successfully.

  • SoPatt Profile Picture
    Microsoft Employee on at

    The issue continues. I have a flow that updates records after they are written and I wonder if there could be some sort of crossing of the streams there. I plan to troubleshoot that tomorrow; I only get to work on this one day a week at best :).

  • SoPatt Profile Picture
    Microsoft Employee on at

    I think my hypothesis was correct, although I didn't really nail down what was happening. Probably a race condition of some kind.

  • Verified answer
    SoPatt Profile Picture
    Microsoft Employee on at

    I'm still fighting this. 


    One thing I've done is implement a "SyncState" field as opposed to the "Edited" field I had before. Updates to PSOCache get updated with {SyncState:0}. Upon writing to PSO (the Sharepoint list), they get updated with {SyncState:1}, and my "Flow" has been altered so it runs when SyncState=1 and it always sets {SyncState:2}

    I have one icon icoWriteBack that contains the following, and this gets run in OnVisible of my gallery form (i.e. after coming back from the New/Edit form).

     

    If(Connection.Connected
     && Concat(PSOCache,If(SyncState=0,"1",""))<>""
     ,ForAll(
     PSOCache
     // Update all cached edits back to db
     ,If(SyncState=0
     ,If(IsBlank(ID)
     ,Patch(PSO
     ,Defaults(PSO)
     ,{ Title: PSOCache[@Title]
     ,Inspected: PSOCache[@Inspected]
     ,Status: PSOCache[@Status]
     ,Bin: PSOCache[@Bin]
     ,Description: PSOCache[@Description]
     ,OwnerName: PSOCache[@OwnerName]
     ,SN: PSOCache[@SN]
     ,VPN: PSOCache[@VPN]
     ,Ticket: PSOCache[@Ticket]
     ,StatusText: PSOCache[@StatusText]
     ,StatusDetail: PSOCache[@StatusDetail]
     ,SyncState:1
     }
     )
     )
     ;UpdateIf(PSO
     ,PSO[@ID]=PSOCache[@ID]
     ,{ Title: PSOCache[@Title]
     ,Inspected: PSOCache[@Inspected]
     ,Status: PSOCache[@Status]
     ,Bin: PSOCache[@Bin]
     ,Description: PSOCache[@Description]
     ,OwnerName: PSOCache[@OwnerName]
     ,SN: PSOCache[@SN]
     ,VPN: PSOCache[@VPN]
     ,Ticket: PSOCache[@Ticket]
     ,StatusText: PSOCache[@StatusText]
     ,StatusDetail: PSOCache[@StatusDetail]
     ,SyncState:1
     }
     )
     )
     )
     ;UpdateIf(PSOCache
     ,SyncState=0
     ,{SyncState:1}
     )
     ;SaveData(PSOCache,"PSOCache")
    )

    I also have icoRefresh which gets triggered by a timer every 30 seconds, or manually.

    If(Concat(PSOCache,If(SyncState=0,"1",""))<>"" // = "If any SyncState is zero"...which would indicate a record that has not been written.
     ,Select(icoWriteBack)
     ,If(Connection.Connected
     ,ClearCollect(PSOCache
     ,Filter(PSO
     ,StatusText = "Pending Pickup"
     || StatusText = "Tech Custody"
     || SyncState <> 2 // records that have not been updated by the "Flow"
     ,OwnerName = UserAlias
     )
     )
     )
    )

    There is also code to essentially disable edits on any record where SyncState <> 2 (in the OnSelect of the gallery) which is dependent in icoSyncing.Visible.

    If(SyncState=2
     Navigate(
     scrEdit,
     ScreenTransition.None,
     {
     Target: ThisItem,
     UpdateGroupItems:false
     }
     )
    )

    What is found is that "sometimes" (and it seems random) I get an error on the UpdateIf (in the first code block above) stating: "Conflicts exist with changes on the server. Please reload." This can happen even after the records have been unchanged for some time, and every datasource is in sync.

     

  • SoPatt Profile Picture
    Microsoft Employee on at

    I've found now that there is an issue with my flow. It keeps running over and over.

     

    The flow condition is:
     Annotation 2019-07-10 135805.jpg"
    But it evaluates to "true" even when SyncState is already 2. I also tried SyncState "is equal to" 1, but that always seems evaluates false. I'm not sure what I'm doing wrong here.


  • SoPatt Profile Picture
    Microsoft Employee on at

    I think the flow issue was this simple:

     

    Annotation 2019-07-10 142555.jpg

    Hopefully that means the prior changes solved the original issue and the flow was a separate issue.

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 392 Most Valuable Professional

#2
11manish Profile Picture

11manish 136 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 109 Super User 2026 Season 2

Last 30 days Overall leaderboard