I have an app that has a lot of necessary code to run OnStart of the app - setting variables/creating collections so the user experience is faster when they use the app.
I have the app going to a welcome screen once the OnStart actions are complete.
I have found that when I include certain ClearCollect statements in the OnStart code it will take nearly 2 mins to get to the welcome screen - If I omit these in the OnStart code it takes less than 5 seconds to get to the welcome screen.
I will display most of the OnStart code first and then the specific ClearCollects that seem to be causing the problem - I think I have rogue code here but Powerapps is not telling me it is so...
Set(
varNewOfficer,
false
);
Set(
varUserMail,
User().Email
);
With(
{_detail: MyDetails},
If(
LookUp(
_detail,
Lower(email) = Lower(varUserMail),
admin
) = true,
Set(
varadmin,
true
)
)
);
ClearCollect(
colContacts,
AddColumns(
BusinessUnits,
"Contact1",
(LookUp(
MyDetails,
personnelno = BusinessUnits[@contact1],
firstname & " " & surname
)),
"Contact2",
(LookUp(
MyDetails,
personnelno = BusinessUnits[@contact2],
firstname & " " & surname
)),
"Contact3",
(LookUp(
MyDetails,
personnelno = BusinessUnits[@contact3],
firstname & " " & surname
)),
"Contact4",
(LookUp(
MyDetails,
personnelno = BusinessUnits[@contact4],
firstname & " " & surname
)),
"Workphone",
(LookUp(
MyDetails,
personnelno = BusinessUnits[@contact1],
workphone
)),
"Homephone",
(LookUp(
MyDetails,
personnelno = BusinessUnits[@contact1],
homephone
)),
"Workmobile",
(LookUp(
MyDetails,
personnelno = BusinessUnits[@contact1],
workmobile
)),
"Homemobile",
(LookUp(
MyDetails,
personnelno = BusinessUnits[@contact1],
homemobile
)),
"Workphone2",
(LookUp(
MyDetails,
personnelno = BusinessUnits[@contact2],
workphone
)),
"Homephone2",
(LookUp(
MyDetails,
personnelno = BusinessUnits[@contact2],
homephone
)),
"Workmobile2",
(LookUp(
MyDetails,
personnelno = BusinessUnits[@contact2],
workmobile
)),
"Homemobile2",
(LookUp(
MyDetails,
personnelno = BusinessUnits[@contact2],
homemobile
)),
"Workphone3",
(LookUp(
MyDetails,
personnelno = BusinessUnits[@contact3],
workphone
)),
"Homephone3",
(LookUp(
MyDetails,
personnelno = BusinessUnits[@contact3],
homephone
)),
"Workmobile3",
(LookUp(
MyDetails,
personnelno = BusinessUnits[@contact3],
workmobile
)),
"Homemobile3",
(LookUp(
MyDetails,
personnelno = BusinessUnits[@contact3],
homemobile
)),
"Workphone4",
(LookUp(
MyDetails,
personnelno = BusinessUnits[@contact4],
workphone
)),
"Homephone4",
(LookUp(
MyDetails,
personnelno = BusinessUnits[@contact4],
homephone
)),
"Workmobile4",
(LookUp(
MyDetails,
personnelno = BusinessUnits[@contact4],
workmobile
)),
"Homemobile4",
(LookUp(
MyDetails,
personnelno = BusinessUnits[@contact4],
homemobile
))
)
);
ClearCollect(
colTrips,
Trips
);
ClearCollect(
colTripDetails,
TripDetails
);
ClearCollect(
colMyDetails,
MyDetails
);
Navigate(
PRIVACYSCREEN,
Fade
);
running that takes less than 5 seconds..........and now the 2 seemingly problematic bits of code:
ClearCollect(
colGalleryData,
AddColumns(
Trips,
"thetripid",
LookUp(
TripDetails,
tripid = tripid,
tripid
)
)
);
ClearCollect(
colTripData,
With(
{
StartDate: Today(),
EndDate: Today() + 5,
Data: AddColumns(
TripDetails,
"Region",
LookUp(
Trips As aTrip,
aTrip.tripid = tripid
).region
)
},
Filter(
Data,
tripdate >= StartDate,
tripdate < EndDate
)
)
);
for reference the Trips SP list has 657 records and the TripDetails list has 1600 approx so we're not talking huge amounts of data..