cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sopatte
Level 8

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
sopatte
Level 8

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

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.
sopatte
Level 8

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.

sopatte
Level 8

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

sopatte
Level 8

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.

sopatte
Level 8

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

sopatte
Level 8

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.


sopatte
Level 8

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
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (4,705)