cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Shay
Level: Powered On

Help on the first offline app- Error in loading offline app data

All, 

I am having some issues in loading my offline collection data. Suppose if I save 5 records offline and then I turned the app online, the app is making 5 copies of last offline entry. 

For example if I submit 5 records offline i.e. a,b,c,d,e and when the app turns online, in the database I will see e 5 times.

 

Below are the codes I wrote, but I am unable to debug them and will really appreciate if any of you can guide me through this-

 

Code on Submit Button-

   

Set(wait,true);

If(
ToggleIsConnected.Value,
Patch(
'Backend-1.5',
Defaults('Backend-1.5'),
{
Title: DataCardValue3.Text&" - "&Now(), // Title was added as it might otherwise cause issues in SPO
ObserverName: DataCardValue3.Text,
ObserverJobTitle: DataCardValue1.Text,
Location: DataCardValue5.Selected,
Date: DataCardValue2.SelectedDate,
AdjustingPersonalProtectiveEquipment: DataCardValue17.Selected,
}
),
Collect(
StopCardCollections,
{
Title: DataCardValue3.Text&" - "&Now(), // Title was added as it might otherwise cause issues in SPO
ObserverName: DataCardValue3.Text,
ObserverJobTitle: DataCardValue1.Text,
Location: DataCardValue5.Selected,
Date: DataCardValue2.SelectedDate,
}
);
SaveData(
StopCardCollections,
"DeviceCache"
)
);
Set(wait,!true);
ResetForm(Form1);
ResetForm(EditForm1);
ResetForm(Form2);
ResetForm(Form3);
ResetForm(EditForm2);
ResetForm(EditForm3);
ResetForm(EditForm4);
ResetForm(EditForm5);
ResetForm(EditForm7);
ResetForm(EditForm8);
ResetForm(EditForm11);
ResetForm(EditForm10);
ResetForm(EditForm9);
Navigate(
'Thank You Screen',
None
)

 

Code on toggle button which checks if the app is connected or not- 

 

If(!IsEmpty(StopCardCollections),

ForAll(StopCardCollections,

Collect(Success,
{id: id,
Record:
Patch('Backend-1.5',Defaults('Backend-1.5'),
{ObserverName: DataCardValue3.Text,
ObserverJobTitle: DataCardValue1.Text,
Location: DataCardValue5.Selected,
Date: DataCardValue2.SelectedDate,
AdjustingPersonalProtectiveEquipment: DataCardValue17.Selected,
ChangingPosition: DataCardValue18.Selected,
RearrangingJob: DataCardValue19.Selected,
StoppingJob: DataCardValue20.Selected,
AttachingGrounds: DataCardValue24.Selected,
PerformingLockouts: DataCardValue22.Selected,
InLineOfFire: DataCardValue12.Selected,
ImproperLifting: DataCardValue13.Selected,
Falling: DataCardValue14.Selected,
ContactingTemperatureExtremes: DataCardValue15.Selected,
ContactingElectricCurrent: DataCardValue16.Selected,
ContactingLimeOROtherHazardousSubstance: DataCardValue21.Selected,
RepetativeMotions: DataCardValue23.Selected,
AwkwardPositionsORStaticPostures: DataCardValue25.Selected,
Head: DataCardValue34.Selected,
EyesAndFace: DataCardValue35.Selected,
Ears: DataCardValue36.Selected,
RespiratorySystem: DataCardValue37.Selected,
ArmsandHands: DataCardValue38.Selected,
HighVisibilityVest: DataCardValue39.Selected,
LegsandFeet: DataCardValue40.Selected,
TaskSpecific: DataCardValue41.Selected,
FallProtection: DataCardValue42.Selected,
RightForTheJob: DataCardValue51.Selected,
UsedCorrectly: DataCardValue52.Selected,
InSafeCondition: DataCardValue53.Selected,
Available: DataCardValue63.Selected,
Adequate: DataCardValue62.Selected,

}
)
}
)
);

If(IsEmpty(Errors('Backend-1.5')),
Clear(StopCardCollections),
Remove(StopCardCollections,Filter(StopCardCollections,id exactin Success.id));
Clear(Success)
)
);

 

Thanks in Advance,

Shay 

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

New Badges

Check it out!

thirdimage

Power Apps 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

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors
Users online (4,887)