cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
P_SA
Helper IV
Helper IV

Offline Powerapps-Sync issue

Hello, I am trying to add an offline functionality in my app. The code is buggy, sometimes it works and sometime it does not. I am seeking your help in this. Below is my code on submit button.

If(
    Connection.Connected ,
Patch(
    'Dev_Data.RecordOut',
    Defaults('Dev_Data.RecordOut'),
    {
        Asset: Dropdown1_2.Selected.Asset,
        AssetLocationFrom: drpFrom.Selected.AssetLocation,
        AssetLocationTo: drpTo.Selected.AssetLocation,
        ByResource: drpByResource.Selected.LabourerName,
        ID: Last('Dev_Data.RecordOut').ID + 1,
        ReturnDate: dteReturn.SelectedDate
    }
);
Refresh('Dev_Data.RecordOut');
ClearCollect(LocalIssues,'Dev_Data.RecordOut');
SaveData(LocalIssues,"offlineissues"),

Collect(localchanges,
{Asset: Dropdown1_2.Selected.Asset,
        AssetLocationFrom: drpFrom.Selected.AssetLocation,
        AssetLocationTo: drpTo.Selected.AssetLocation,
        ByResource: drpByResource.Selected.LabourerName,
        ID: Last(localchanges).ID + 1,
        ReturnDate: dteReturn.SelectedDate,
        ChangeType : "a"});
        SaveData(localchanges,"offlinechanges");
        
        UpdateContext({popup:true}))
        
        
        
           

and this is the code in the timer on end.

If(
    Connection.Connected  && CountRows(localchanges) > 0,
    ForAll(
        localchanges,
        If(
            ChangeType = "a",
            Patch(
                'Dev_Data.RecordOut',
                 Defaults('Dev_Data.RecordOut'),            
                                {
                    Asset: Dropdown1_2.Selected.Asset,
                    AssetLocationFrom: drpFrom.Selected.AssetLocation,
                    AssetLocationTo: drpTo.Selected.AssetLocation,
                    ByResource: drpByResource.Selected.LabourerName,
                    ID: Last('Dev_Data.RecordOut').ID +1 ,
                    ReturnDate: dteReturn.SelectedDate
                }
            )
        )
    )
);
Clear(localchanges);
Refresh('Dev_Data.RecordOut');
ClearCollect(
    LocalIssues,
    'Dev_Data.RecordOut'
);
SaveData(
    LocalIssues,
    "offlineissues"
)

 

 

 

The data collected offline does not sync all the time, but sometimes it does. My doubt is with the ID column in the source.

Also, the datasource I have is MySql.

 

Please suggest. thanks in advance.

0 REPLIES 0

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (39,867)