Hi All,
How can I autopopulate data in offline mode?
I have a entity named ‘Contact’ as below:
Display name Name Data type Type Required
Contact crb56_contact Unique Identifier standard Yes
Full name crb56_fullName Text Custom optional
Email crb56_emailType email Custom optional
<more fields not relevant to this post>
I have another custom entity named ‘ChecklistData’ as below:
Display name Name Data type Type Required
Checklist crb56_ChecklistID Unique Identifier standard Yes
Contact Lookup crb56_contcatChecklist Lookup Custom optional
Item crb56_ItemChecklist Text Custom optional
Answer crb56_AnswerChecklist Option Set Custom optional
As you can see, crb56_contcatChecklist is a lookup field that points to a record in contact entity.
Now, based on logged in user I want to fetch Checklist (Unique Identifier) in offline mode.
Currently, I am using this formula which is working but giving me delegation error-
If(Connection.Connected,
LookUp(Buses,'Contact Lookup'.Contact=LookUp(Contacts,Email=loggedinuseremail,Contact),Bus),
LookUp(BusCollection,'Contact Lookup'.Contact=LookUp(ContactCollection,emailaddress1=loggedinuseremail,contactid),Bus))
where loggedinuseremail=user().email
I am not not sure for offline mode.
Solved! Go to Solution.
Hi @Tejasvi_munge
First of all, your formula is correct and will work both in online and offline mode. However you are receiving a delegation warning due to the lookup structure of your statement.
First of all, a delegation warning means that the operation yo are executing will not be delegated to the data source, meaning that the app will do all the data processing work. This means that the data retrieved from the data source will be limited to the first n rows (max 2000 currently) and with large data sources, info will be dismissed due to this delegation warning.
Your delegation warning appears when you are executing a Lookup in which the condition clause includes another Lookup searching in a different data source. In particular, the part of your code which is producing the delegation warning is highlighted in bold:
If(Connection.Connected,
LookUp(Buses,'Contact Lookup'.Contact=LookUp(Contacts,Email=loggedinuseremail,Contact),Bus),
LookUp(BusCollection,'Contact Lookup'.Contact=LookUp(ContactCollection,emailaddress1=loggedinuseremail,contactid),Bus)
)
I usually work with user login parameters in PowerApps and I found the best practice is to store your user login data into a variable at the start of the app, in App->OnStart property. If you do so and lets say store your user data like:
Set(_UserData,LookUp(Contacts,Email=loggedinuseremail))
Then you can simply substitute:
If(Connection.Connected,
LookUp(Buses,'Contact Lookup'.Contact=LookUp(Contacts,Email=loggedinuseremail,Contact),Bus),
LookUp(BusCollection,'Contact Lookup'.Contact=LookUp(ContactCollection,emailaddress1=loggedinuseremail,contactid),Bus)
)
With:
If(Connection.Connected,
LookUp(Buses,'Contact Lookup'.Contact=_UserData.contact,Bus),
LookUp(BusCollection,'Contact Lookup'.Contact=LookUp(ContactCollection,emailaddress1=loggedinuseremail,contactid),Bus)
)
This way the delegation warning is gone.
NOTE: You should do the same in any other part of your code referencing your user info such as Email, FullName or Contact:
Hope this helps
Hi @Tejasvi_munge ,
Do you want to filter based on current user in offline mode?
The key point is that the device could not get current user's email when the app is in offline mode, which means that "user().email" will return blank.
What's more, you could not load CDS data in offline mode.
You could only save all the data in these two entities in local when you are in online mode.
Then filter the saved data based on manually entered email to filter.
Try this formula:
1)set the app's OnStart:
If( Connection.Connected,
ClearCollect(Contactcollection,Contact);
ClearCollect(ChecklistDatacollection, ChecklistData);
SaveData( Contactcollection, "Contactcollection" );
SaveData( ChecklistDatacollection, "ChecklistDatacollection" );
Set(loggedinuseremail,User().Email),
//if connected, save data
LoadData( Contactcollection, "Contactcollection" , true);
LoadData( ChecklistDatacollection, "ChecklistDatacollection" , true);
//if not connected, load data
)
2)insert a textinput to enter email
(could not load current user's email automatically when in offline, so you could enter by yourself)
set the textinput's Visible:
If(Connection.Connected,
false,
true)
3)set the gallery's Items:
If(Connection.Connected,
LookUp(Buses,'Contact Lookup'.Contact=LookUp(Contacts,Email=loggedinuseremail,Contact),Bus),
//if connected, use currect user to filter based on entities
LookUp(ChecklistDatacollection,'Contact Lookup'.Contact=LookUp(Contactcollection,Email=Textinput1.Text,Contact),Bus)
//if not connected, use textinput to filter based on collections
)
Best regards,
Hi @Tejasvi_munge
First of all, your formula is correct and will work both in online and offline mode. However you are receiving a delegation warning due to the lookup structure of your statement.
First of all, a delegation warning means that the operation yo are executing will not be delegated to the data source, meaning that the app will do all the data processing work. This means that the data retrieved from the data source will be limited to the first n rows (max 2000 currently) and with large data sources, info will be dismissed due to this delegation warning.
Your delegation warning appears when you are executing a Lookup in which the condition clause includes another Lookup searching in a different data source. In particular, the part of your code which is producing the delegation warning is highlighted in bold:
If(Connection.Connected,
LookUp(Buses,'Contact Lookup'.Contact=LookUp(Contacts,Email=loggedinuseremail,Contact),Bus),
LookUp(BusCollection,'Contact Lookup'.Contact=LookUp(ContactCollection,emailaddress1=loggedinuseremail,contactid),Bus)
)
I usually work with user login parameters in PowerApps and I found the best practice is to store your user login data into a variable at the start of the app, in App->OnStart property. If you do so and lets say store your user data like:
Set(_UserData,LookUp(Contacts,Email=loggedinuseremail))
Then you can simply substitute:
If(Connection.Connected,
LookUp(Buses,'Contact Lookup'.Contact=LookUp(Contacts,Email=loggedinuseremail,Contact),Bus),
LookUp(BusCollection,'Contact Lookup'.Contact=LookUp(ContactCollection,emailaddress1=loggedinuseremail,contactid),Bus)
)
With:
If(Connection.Connected,
LookUp(Buses,'Contact Lookup'.Contact=_UserData.contact,Bus),
LookUp(BusCollection,'Contact Lookup'.Contact=LookUp(ContactCollection,emailaddress1=loggedinuseremail,contactid),Bus)
)
This way the delegation warning is gone.
NOTE: You should do the same in any other part of your code referencing your user info such as Email, FullName or Contact:
Hope this helps
Check out new user group experience and if you are a leader please create your group
Did you miss the call?? Check out the Power Apps Community Call here!
See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.
User | Count |
---|---|
251 | |
251 | |
84 | |
36 | |
32 |
User | Count |
---|---|
337 | |
260 | |
122 | |
72 | |
45 |