Search code examples
powerappspowerapps-datatablepowerapps-collection

PowerApps datatable lookup column won't show choices


We are building a PowerApps screen with a data table using a collection as the data source for the Items property.

In our onVisible event of the screen we create the collection like this:

ClearCollect(
    collTrackedSales,
    Filter(
        eBayIT_Item_Management,
        TCode = "A02"
    )
)

eBayIT_Item_Management is the actual SharePoint list, and this includes a lookup column to another list called ItemCategories ...

The problem is that the column in the data table just shows [object Object] in that column...

I have created another data table on the screen just using the SP List as the source and it works fine...

Here are the images showing the problem: enter image description here

in the above picture you can see there is no problem displaying the categories field.

In the below picture you can see there is an issue when using a collection as the source of the 2nd datatable:

enter image description here

So what can I do in order to show the actual values in that list instead of object Object?


Solution

  • SharePoint lookup columns are stored in the original table as a "pointer" to an item in the referenced table, and in PowerApps they're stored as an object that contains the value and the identifier of the referenced table. If you use a SharePoint list directly as the data source of a data table, then the PowerApps knows that it's a SharePoint reference, and it can "follow the reference" to retrieve the value.

    However, once you save the data from from eBayIT_Item_Management to a local collection, PowerApps doesn't know anymore that it has a reference to another list; instead it only has the data that was copied from the original list.

    You can, however, when creating your local collection, extract the reference from the lookup column and save it directly in your local collection, by using an AddColumns expression, as follows:

    ClearCollect(
        collTrackedSales,
        AddColumns(
            Filter(
                eBayIT_Item_Management,
                TCode = "A02"
            ),
            "CategoryName",
            Category.Value
        )
    )
    

    And if you use the new column CategoryName in your data table, it will show you the data you want.