cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
Microsoft
Microsoft

Re: Issue: Inconsistent Sharepoint Updates

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
Highlighted
Dual Super User III
Dual Super User III

Re: Issue: Inconsistent Sharepoint Updates

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.
Highlighted
Microsoft
Microsoft

Re: Issue: Inconsistent Sharepoint Updates

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.

Highlighted
Microsoft
Microsoft

Re: Issue: Inconsistent Sharepoint Updates

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

Highlighted
Microsoft
Microsoft

Re: Issue: Inconsistent Sharepoint Updates

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

Highlighted
Microsoft
Microsoft

Re: Issue: Inconsistent Sharepoint Updates

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

Highlighted
Microsoft
Microsoft

Re: Issue: Inconsistent Sharepoint Updates

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.


Highlighted
Microsoft
Microsoft

Re: Issue: Inconsistent Sharepoint Updates

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
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (6,738)