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

ComboBox default not working in Form Context Variable holding LookUp instead of LookUp as Item

Hello

Please be so kind as to read my full post before responding.
In one PowerApp of mine I have a weird issue with the DefaultSelectedItems apparently not working.

In one EditScreen with an EditForm containing a ComboBox with Items,

Choices([@'Auslieferungen (WA)'].kk_warehouse_collector_id)

kk_warehouse_collector_id being a LookUp field, and DefaultSelectedItems

ThisItem.kk_warehouse_collector_id

and Form.DataSource

[@'Auslieferungen (WA)']


On AnotherScreen containing a Gallery with Items 

[@'Auslieferungen (WA)']

and an GoToDetails Button in the template with OnSelect

Navigate(EditScreen, None, {
    selectedDelivery: LookUp([@'Auslieferungen (WA)'], kk_warehouse_deliveryid=UebersichtGallery.Selected.kk_warehouse_deliveryid)
})


Now to the weird part:
If I set EditForm.Item to

selectedDelivery

then the ComboBox doesn't get properly initialized with default values from the selected Record and it only shows InputTextPlaceholder/NoSelectionText.
image.png
If I set EditForm.Item to

LookUp([@'Auslieferungen (WA)'], kk_warehouse_deliveryid=selectedDelivery.kk_warehouse_deliveryid)

and in essence repeat the LookUp I just did in the Navigate function, then suddenly the ComboBox default works.
image.png

 

  1. What is happening here?
  2. Why can't I directly use selectedDelivery, which as far as I understand gets set to the same thing in the context variable part of Navigate?

Last tested with:

App ID: 8200a3f3-30fd-44f9-b3b7-0c9e0f803c50
Session ID: 21a66c2e-a2f6-472c-bffc-a84600ce0745
PowerApps 3.19081.26


Thank you,
    Sa.
4 REPLIES 4
Community Support Team
Community Support Team

Re: ComboBox default not working in Form Context Variable holding LookUp instead of LookUp as Item

Hi @SaWu , 

Could you please share a bit more about the 'Auslieferungen (WA)' data source within your app? Is it a SP list?

 

Based on the issue that you mentioned, I have made a test on my side, and don't have the issue that you mentioned.

 

Please consider use a global variable to store selected item in your Gallery rather than use Context variable. Within the Gallery of your BrowseScreen, set the OnSelect property of the "GoToDetails" button to following formula:

 

Set(CurrentSelectedItem, LookUp([@'Auslieferungen (WA)'], kk_warehouse_deliveryid = UebersichtGallery.Selected.kk_warehouse_deliveryid));
Navigate(
         EditScreen, 
         ScreenTransition.None
)

Or

Set(CurrentSelectedItem, ThisItem);
Navigate(
         EditScreen, 
         ScreenTransition.None
)

 

Then set the Item property of the Edit form to following:

CurrentSelectedItem

 

In addition, I think it is not necessary to bind the Item property of the Edit form to a variable, instead, you could bind the Item property of the Edit form to the selected item in your Gallery directly.

 

Please consider take a try with above solution, check if the issue is solved.

 

Best regards,

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
SaWu
Level 8

Re: ComboBox default not working in Form Context Variable holding LookUp instead of LookUp as Item

Hello @v-xida-msft 

Thank you for your reply.

I am not using Sharepoint.
My whole app is purely CDS/Dynamics.
That is "Auslieferungen (WA)" is a CDS/Dynamics Table (and plural name) of a custom entity "Auslieferung (WA)" (kk_warehouse_delivery).
This custom entity also contains a LookUp field "kk_warehouse_collector_id" to another custom entity (kk_warehouse_collector).
The ComboBox is exactly for this LookUp field.

I know that I can bind the Form directly to Gallery.Selected but this has it's own set of drawbacks, see also:
https://powerapps.microsoft.com/en-us/blog/decouplingbrowsegalleryfromforms/
https://blogs.msdn.microsoft.com/carlosfigueira/2017/10/04/decouplingbrowsegalleryfromforms/

Also, please note that the screen transition of Navigate has been optional since several versions of PowerApps releases, see also
https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-navigate
image.png
In my example I need to put in None for the optional Transition argument to "reach" the UpdateContextRecord argument.

I will try to see if there is a difference with a global variable.

Thanks,
    Sa.

Community Support Team
Community Support Team

Re: ComboBox default not working in Form Context Variable holding LookUp instead of LookUp as Item

Hi @SaWu ,

Have you taken a try with the global variable I mentioned above?

Have you solved your problem?

 

Actually, I think it is not necessary to set a variable to store the selected item within the Gallery. Instead, you could consider bind the Edit form within the selected item in your Gallery directly using the following formula:

Gallery1.Selected

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
SaWu
Level 8

Re: ComboBox default not working in Form Context Variable holding LookUp instead of LookUp as Item

Hello @v-xida-msft 

I want to stress again that, as previously posted, I have a workaround (putting the LookUp into Form.Item).

Still I have tried your propositions.
I tried using Set and a global variable instead of UpdateContext and a context variable.
image.pngimage.png
Still, the ComboBoxes for the lookup fields don't populate.
image.png

I also tried using Gallery.Selected to see if the ComboBoxes populate, and they do.
image.pngimage.png
However, as already posted in my previous answer to you, I have other preconceptions, supported by PowerApps blog articles, that make me want to avoid using Gallery.Selected.
One important point is that creating a new record, saving it, and still show the edit form for this new record allowing further changes, while never leaving the edit form screen, is impossible to do by using Gallery.Selected (as far as I know).
But exactly this scenario is one of the most common use cases for our users.

My guess, which you might want to forward to the backend team, would be that saving a record with lookup fields (as either global or context variables) somehow messes with the "links" behind those lookups, such that the ComboBox can't expand those lookups, for example to look for SearchFields or DisplayFields, resulting in the default values of the ComboBox not being populated by the "truncated"/saved record with lookup fields.
Obviously, putting the LookUp or Gallery.Selected into Form.Item avoids this issue as the "original" record with the "full" lookup fields is there.

Thank you,
    Sa.

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.

Top Kudoed Authors (Last 30 Days)
Users online (4,552)