cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PytByt
Level 8

Re: Help with LookUp Columns - CDS Entities returning null data for lookups in PowerApps

Hi @AccuFloDev 

I'm new with powerapps, thats why i need to reanimate this thread..

 


@AccuFloDev wrote:

 


In regards to my issue, I'm trying to improve performance of an app by making it work mostly offline until the user initiates a sync on demand. 


Could you please share me the formula for this part please?

Thanks,

 

BR.

pytbyt

 

 

AccuFloDev
Level: Powered On

Re: Help with LookUp Columns - CDS Entities returning null data for lookups in PowerApps


@PytByt wrote:

Hi @AccuFloDev 

I'm new with powerapps, thats why i need to reanimate this thread..

 


@AccuFloDev wrote:

 


In regards to my issue, I'm trying to improve performance of an app by making it work mostly offline until the user initiates a sync on demand. 


Could you please share me the formula for this part please?

Thanks,

 

BR.

pytbyt

 

 


Hey @PytByt ,

The functionality I was describing isn't all in a single formula - could you be more specific as to the information you're looking for?  I'll try to provide what I can.

AccuFloDev
Level: Powered On

Re: Help with LookUp Columns - CDS Entities returning null data for lookups in PowerApps

Hey @KelvinBox ,


I was unable to get the lookups to show using labels on a page prior to the call to Collect().
I was however able to get the lookups working using a slightly different method;
I may also have found an alternative to using First() that may have less of a hit on the device storage:

 

Here's a basic outline of the steps I used:

  1. On app launch, navigate to a 'splash' screen which will grab online data (if connected) through a series of buttons which iterate through all the entities I need to grab.

  2. On this same page, I have added forms for every entity with lookup values I need to pull in: 1-form-per-entity.
    Each form has DataCards for the following:

    1. A DataCard for each required lookup column.
      • Ensure that the Combo Box for the lookup field shows a value that is guaranteed to have data, such as the Id column of the lookup entity.

    2. A DataCard for the Entity's Id (The Entity with the lookup column, not the lookup's Id)
      This will reassure you that you are indeed getting entity data.

  3. Set the DataSource property of each form to a CDS Entity you need lookup columns for.

  4. On the Items property of each form, use code similar to the example below to pull in a single row.
    According to Microsoft the code is delegable , so hopefully this avoids the caching issue when using First()
    LookUp(
        'My Entity', //CDS Entity
        Not(IsBlank('My Entity Id')) //Get an item where the ID column isn't blank (This guarantees you get a result, if one exists - ID can't be blank)
    )
  5. (Optional) Set the Visibility of these forms to false unless some debug flag is active

  6. After data has been cached on the splash page, navigate to your app's first screen (where your galleries and forms should be).

This has worked to get the lookups showing consistently.  I am running into another issue now with having to Refresh() data sources twice before data comes in, but at least it's bringing in the Lookup values now.
(I will be creating a separate thread on the Refresh issue)

 

Anyway, if you have any questions on my methodology above please let me know.

PytByt
Level 8

Re: Help with LookUp Columns - CDS Entities returning null data for lookups in PowerApps

Hi @AccuFloDev 

I need to know what formula is use to make the offline features. 

I mean, i already use the collection, and i also know about the SaveData and LoadData function. But i haven't really know how to use it and where to put it.

 

That's is why i'm interest in your solution which make the app work mostly offline until the user initiates a sync on demand.

 

I also need to know to automatically sync when Connection is connected.

 

Hope you could help.

 

Thank,

BR.

pytbyt

AccuFloDev
Level: Powered On

Re: Help with LookUp Columns - CDS Entities returning null data for lookups in PowerApps


@PytByt wrote:

Hi @AccuFloDev 

I need to know what formula is use to make the offline features. 

I mean, i already use the collection, and i also know about the SaveData and LoadData function. But i haven't really know how to use it and where to put it.

 

That's is why i'm interest in your solution which make the app work mostly offline until the user initiates a sync on demand.

 

I also need to know to automatically sync when Connection is connected.

 

Hope you could help.

 

Thank,

BR.

pytbyt




Hey @PytByt ,

That's a bit of a loaded question, I'm not sure if I can provide you enough info here in the forums to cover that broad topic, but I can point you in the right direction to some blog articles on the subject take a look at these and let me know if you have any specific questions that aren't covered in the articles:

 

  1. Implementing Offline Capabilities for Relational Data
  2. Implementing Offline Capabilities in your App
  3. Develop offline-capable canvas apps

 

In regards to:

I also need to know to automatically sync when Connection is connected.


There are probably a lot of ways to do this, but my preferred method is to have a button on the apps 'main' screen which runs the 'sync' code.  You could trigger this in a couple of ways:

 

  1. Use the Screens OnVisible property to detect if connected and if so, click the sync button.
    This will have the behaviour of syncing when the screen first loads when the device is connected:
    //Screens OnVisible Property
    If(
      Connection.Connected,
      Select('Sync Button');
    );
  2. To have a screen automatically detect a change in the connection state then run the sync, you could use a Toggle control on the page you wish to do that on, set up something like this:

    *Disclaimer - I haven't tested this code to see if it works, please let me know if you have issues*
    //Toggle Control 'Default' Property
    Connection.Connected
    //Toggle Control 'OnCheck' Property
    //This code will run only when the connection state changes from false to true
    Select('Sync Button');
    You can then set the Visible property of the toggle to false to the users can't manually change the toggle.

Helpful resources

Announcements
thirdimage

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

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Users Online
Currently online: 155 members 5,407 guests
Please welcome our newest community members: