In Part 4 of this series we covered how to filter child records based on selected parent. We added Product gallery list on Company Detail form to shown company’s products. In this blog we will add Product Detail Screen which will open when user selects product from Product Gallery. Primarily focus would be how to handle lookups (dropdown) for parent-child relation in terms of:

  • Pre-Populate Lookup
  • Set default Lookup value for selected item

Add Product Detail Screen:

  • Select Insert tab and click on New Screen, select Form Screen which will automatically add Edit screen to your app. Update title to “Product Detail” and Click on Connect to data

PA1

  • Select data source, “Company Products” in my case. Select Data Cards to be added to Product Detail form. I have added “Product Name”, “Company”, “Expiration Date” and “Is Expired” cards

PA2

  • Bind this edit form with selected Product from Product Gallery. Set Items property of Edit Form as “Gallery1.Selected”. All fields will be automatically set based on selected value, but Company Lookup will still be blank.

PA3

To fix Company Lookup, we need to delete dropdown datacard from Company datacard and add a new dropdown control inside Company datacard.

Add Dropdown for Company Lookup:

  • Note down dropdown datacard name before deleting as it is referred at Parent level, hence we need to keep same name for new dropdown control. In my case it is “DataCardValue18”. Select and delete it.

PA4

  • Before adding new control to Company datacard, you need to unlock it first. Select Company datacard, go to Advanced tab and click on Unlock button
  • Select Company datacard, from Insert tab click on Controls and select “Drop down” option to add dropdown control inside Company datacard. Rename dropdown control to “DataCardValue18”.

PA5

Populate Dropdown:

  • By default, dropdown is populated with sample data containing some numbers. To display companies data we need to add a data source for Companies first and then change Items property of dropdown to refer Companies data source.
  • Select drop down and change Items property to “Companies” data source and select “cr2a5_companyname” as Value.

PA6

Set Default Value for Dropdown:

  • Now dropdown shows companies data but in order to set default value based on selected product, we need to change Default property of dropdown control.
  • Select dropdown and change Default property value to “cr2a5_Company1.cr2a5_companyname”. You will see dropdown default value will be updated based on selected Product. Here “ThisItem” refers to EditForm.Item which is set to “Gallery1.Selected” as mentioned above. So above formula will return company name for selected product.

PA7

Part 4