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

Dropdown default

My datasources are two sharepoint lists: Customers and Orders. Orders are linked to Customers (lookup column).

 

I have one screen where the user can select a customer from a gallery. In this screen the user can click "Details" to navigate to the orders screen.

 

The orders screen lists the orders (in a gallery) for the selected customer and a form details the orders when the user makes a selection in this gallery. The user can then add/edit/delete orders from this screen. Edit and delete works great.

 

The issue I'm having is when the user wants to add an item (NewForm() is called and all fields are reset) - the Customer dropdown should of course have the default value of the previously selected customer (in the previous screen).

 

I've unlocked the Customer lookup datacard and tried to override the default value by doing a lookup to the Customer list, but the dropdown is empty.

 

What are the steps necessary to make this work? Is there some syntax or steps that I've overlooked?

1 ACCEPTED SOLUTION

Accepted Solutions
JohnP
Level 8

Re: Dropdown default

I figured this out from doing some research.... the default value of the dropdown should be like this when you're dealing with SharePoint lookup fields:

 

{'@odata.type' : "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
Id : BrowseGallery1.Selected.ID,
Value: BrowseGallery.Selected.Title}

 

No need to check for edit or new mode either 🙂

View solution in original post

5 REPLIES 5
Delid4ve
Level 10

Re: Dropdown default

firstly your going to need to store the last value of the dropdown in a variable using the set function, this would probably be best in the Onchange property of the dropdown.

Secondly In the dropdown default i think your going to need to use an if statement to check what mode the form is in.

If its in edit then use the lookup for the current record, if in new then use the variable.

 

Community Support Team
Community Support Team

Re: Dropdown default

Hi @JohnP,

 

The question here is, what is the Customer field data type under the Orders list, is it a Person or group type?

If that is, and the Customer list also has a Customer Field (Should also be the Person or Group type), then we could configure the default property of the Corresponding Dropdown control with the code below:

If(Editform1.mode=1, Gallery1.Selected.Customer, Parent.Default)

Doing this should meet your requirements.

 

Regards,

Michael

 

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

Re: Dropdown default


@Delid4ve wrote:

firstly your going to need to store the last value of the dropdown in a variable using the set function, this would probably be best in the Onchange property of the dropdown.

Secondly In the dropdown default i think your going to need to use an if statement to check what mode the form is in.

If its in edit then use the lookup for the current record, if in new then use the variable.

 


@Delid4veWhat if there are no orders for the selected customer? Then there is no last value to save...

JohnP
Level 8

Re: Dropdown default


@v-micsh-msft wrote:

Hi @JohnP,

 

The question here is, what is the Customer field data type under the Orders list, is it a Person or group type?

If that is, and the Customer list also has a Customer Field (Should also be the Person or Group type), then we could configure the default property of the Corresponding Dropdown control with the code below:

If(Editform1.mode=1, Gallery1.Selected.Customer, Parent.Default)

Doing this should meet your requirements.

 

Regards,

Michael

 


@v-micsh-msftCurrently in the Orders list I have one field called CustomerLookup which is a Lookup field to the Customer list. I have tried your suggestion with the following syntax (default value of dropdown):

 

If(OrderForm.Mode=New, CustomerGallery.Selected, Parent.Default)

 

Works in edit mode, but not when I try to add a new item (dropdown is blank). The problem is, I think, that the selected property is not compatible with the lookup column. But PowerApps does not report any error.

JohnP
Level 8

Re: Dropdown default

I figured this out from doing some research.... the default value of the dropdown should be like this when you're dealing with SharePoint lookup fields:

 

{'@odata.type' : "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
Id : BrowseGallery1.Selected.ID,
Value: BrowseGallery.Selected.Title}

 

No need to check for edit or new mode either 🙂

View solution in original post

Helpful resources

Announcements
New Ranks and Rank Icons in April

'New Ranks and Rank Icons in April

Read the announcement for more information!

Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (8,779)