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.