cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
DennisKuhn
Level: Powered On

How to sort a Lookup

Hello,

when I add a Lookup column RiskLevel on a Form, the DataCard contains a Lookup control instead of a Dropdown control. The rows should be sorted by a field called NumberValue, but it is sorted by the display value.

 

TitleNumberValue
Low0
High1
Very High2

 

The Lookup shows the values in the alphabetical order "High" - "Low" - "Very High".

I tried replacing the Lookup with a Dropdown with Items set to SortByColumns( RiskLevel, "NumberValue"), the rows are now sorted as I like, but I am not able to update the data. When I set in the DataCard the Update to MyDropDown.Selected, then Submit form call fails.

 

Any help is much appreciated,

Dennis

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: How to sort a Lookup

Hi @DennisKuhn,

 

Lookup field is a little different than the other type fields, it is defined as record type, and has its own structure.

So when submitting new data for this field, we need to submit a record.

Please check the following thread for more details:

How to patch a SharePoint Lookup Column

 

Once you switch the Lookup control to a Dropdown, the value would be switched to Text type.

To workaround it, we need to add a record in the Update property of the DataCard, which should be:

{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
                        Id:Lookup(LookupList,Title=Dropdown.Selected.Value, ID),
                        Value: Dropdown.Selected.Value}

Change the formula as the example above should make it work.

 

Please take a try and see if that works.

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.

View solution in original post

4 REPLIES 4
Super User
Super User

Re: How to sort a Lookup

Hi Dennis,

 

If NumberValue is the value that you want to store, try changing your update property to MyDropDown.Selected.NumberValue

DennisKuhn
Level: Powered On

Re: How to sort a Lookup

Hi timl, thanks for your reply. I just wanna use NumberValue to sort the Items in the Lookup dropdown, instead of them automatically sorted alphabetically.

Community Support Team
Community Support Team

Re: How to sort a Lookup

Hi @DennisKuhn,

 

Lookup field is a little different than the other type fields, it is defined as record type, and has its own structure.

So when submitting new data for this field, we need to submit a record.

Please check the following thread for more details:

How to patch a SharePoint Lookup Column

 

Once you switch the Lookup control to a Dropdown, the value would be switched to Text type.

To workaround it, we need to add a record in the Update property of the DataCard, which should be:

{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
                        Id:Lookup(LookupList,Title=Dropdown.Selected.Value, ID),
                        Value: Dropdown.Selected.Value}

Change the formula as the example above should make it work.

 

Please take a try and see if that works.

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.

View solution in original post

DennisKuhn
Level: Powered On

Re: How to sort a Lookup

Thanks a lot, that worked 🙂 I used the ID from the Dropdown.Selected instead of the LookUp:

 

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

 

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 (9,184)