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

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Demo Extravaganza Championship Voting Open

Voting Ends: October 30, 2019!

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

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

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

Top Kudoed Authors
Users Online
Currently online: 187 members 4,511 guests
Please welcome our newest community members: