Add lookup fields in an editable grid using PowerApps

Introduction:

We had a requirement where we wanted to show the editable grid in power apps. The fields which are suppose to show are of string, decimal and lookup. Other data type was easy to display but we find difficulties in showing the lookup value.

 

In this blog, we will learn how to add lookup fields(combo box) into the editable grid and also save it in Dynamics 365 CRM.

 

Steps:

1. Insert Gallery : 

  1. Insert a new gallery – Insert > Gallery > Blank Vertical
  2. Add Data Source to the Gallery
  3. Go to Properties > Click Data Source you want.

2. Add Combo Box input control in the PowerApps Grid.

    I have added 3 Combo Box input control inside the Grid, 2 text box, 1 is currency field in the data source and a Save icon.

3. For each Combo Box input box:

Item Property:

Set ComboBox.Item = Choices([@'Data Source'].<Field Name>)

For eg: RoleComboBoxRP_1.Item = Choices([@'Role Prices'].Role)


DefaultSelectedItems property:

Set ComboBox.DefaultSelectedItems = ThisItem.<Field Name>

For eg: RoleComboBoxRP_1.DefaultSelectedItems = ThisItem.Role

4. For each text input box:

Default property:

Set TextInput.Default = ThisItem.<Field Name>

For eg: DescriptionRP_1.Default = ThisItem.Description

Note: Do not forget to set the <DefaultSelectedItems> properties or else the value wont be visible in the grid.

5. To Save the changed value into the Data source, set the Save Icon to the following:

OnChange property:

Set SaveIcon.OnChangePatch(DataSource, ThisItem, {
<fieldName>: TextInput.Text,
<fieldName>:ComboBoxName.Selected,
<fieldName>:Value(CurrencyTextInput.Text) 
})

For eg: SaveRP_1.OnChangePatch([@'Role Prices'], ThisItem, {
Role : RoleComboBoxRP_1.Selected,
'Resourcing Unit':ResourcingUnitComboBoxRP_1.Selected,
 Unit:UnitComboBoxRP_1.Selected,
Description:DescriptionRP_1.Text,
Price:Value(PriceRP_1.Text)
})

6. The Output Screen.

7. The changed Lookup value.
If you click the Save Icon the changed values will be saved.

In this way we can change the Lookup values and also Save the changed value in the Dynamics 365 CRM.


Share Story :