cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper V
Helper V

Auto population of data in offline mode

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Resolver II
Resolver II

Re: Auto population of data in offline mode

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



View solution in original post

2 REPLIES 2
Highlighted
Community Support
Community Support

Re: Auto population of data in offline mode

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,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Resolver II
Resolver II

Re: Auto population of data in offline mode

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



View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors
Users online (5,996)