cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Microsoft
Microsoft

Issue: Inconsistent Sharepoint Updates

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
        )    
    )

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

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.

 

View solution in original post

7 REPLIES 7
Dual Super User III
Dual Super User III

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.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

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.

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 :).

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

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.

 

View solution in original post

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.


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.

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (68,950)