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.
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.
Last tested with:
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,
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
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.
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,
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.
Still, the ComboBoxes for the lookup fields don't populate.
I also tried using Gallery.Selected to see if the ComboBoxes populate, and they do.
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.
User | Count |
---|---|
139 | |
132 | |
75 | |
72 | |
68 |
User | Count |
---|---|
213 | |
200 | |
64 | |
62 | |
54 |