PowerApps: Single value lookups SharePoint in Datacards

Why?

Sometimes you just want to use the lookup columns that SharePoint can provide in a PowerApp that has multiple screens. I would not recommend it, in by far the most cases it is not even necessary but…… for those few times you need to make it happen, let me show you 💡

What?

An explanation of how you can get single value lookups from SharePoint to work in a PowerApp that has multiple screens.

How?

So we have a SharePoint list where we want to save information from a PowerApp. In my example this will be the list ListRequests.
In this PowerApp we will have a Dropdown control in Screen 1. In my example I call this dropdown: DropRequestType. The values of this dropdown need to come from a source SharePoint list so the business can manage the options themselves in this other list: SourceListRequestType. We created a lookup column so the lists are linked: RequestTypeLookUp. For a best practice (and easy PowerApps management when building), I always use a different column for the lookup instead of the Title column: imagine you have multiple lookups then you need to make sure you are using the correct Title column in the correct syntax. In my example I created a separate column: RequestTypeText.
For submitting the data to your SharePoint list we want to use the Forms Control in Edit mode that is placed in the last screen.

1) My first thought was: “Simple!, just change the Default property of the Datacard to that of the item selected in the dropdown control and done.”

DropRequestType.SelectedText

If you have done this, you will probably have noticed that even though the Datacard shows value of the option selected in the Dropdown control, the PowerApp does not save the value of the selected option to SharePoint!

2) To achieve this we will also need to change the Update propery of the Datacard to the following:

{
    '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
    Id: DropRequestType.SelectedText.ID
    ,
    Value:  DropRequestType.SelectedText.Value
}

Because (single value) lookup columns are like mini-records the PowerApp needs to treat it as such. Therefor it needs to pass on the selected ID as well as the Selected Value in a JSON like notation, to be able to save it to the SharePoint List.

Multi value lookup columns will be my next post so stay tuned!

One thought on “PowerApps: Single value lookups SharePoint in Datacards

Leave a comment