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

Default Dropdown Value Not Working?

Hi all,

 

I've previously been using a workaround that I found on this forum to set a default value for a dropdown based on a variable which is storing a text value (found here)

 

If(SharePointForm1.Mode = New, {
'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
	Value:"Blue"}, 
ThisItem.FavoriteColor)

 

This has all of a sudden stopped passing this value off to my SharePoint list when saving. It still displays the expected value in my PowerApp, but doesn't actually use it when saving the item.

 

I have noticed there is a semi-new "Combo Box" dropdown item which can be used in a form, but this odata-type workaround does not work in it. Instead, I can set the "DefaultSelectedItems" control to my intended value which appears to work in the app, but again when saving it doesn't actually pass it through to the SharePoint record.

 

Is there a new definitive way to set a default value for a dropdown?

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Default Dropdown Value Not Working?

Hi Andrew,

 

Check out this blog by Carlos Figuera, there is a section for Lookup column defaults.

Herewith the excerpt, but give the blog a read, it's great for various complex column types;

 

Lookup columns

Those are columns for which the user can select a value from another table. This time, using the value only is not enough - it's possible that there are multiple items in the table that is being looked up that have the same value for the referenced column, so we also need to specify the Id property of those values. The best way to retrieve it is to use the Choices function, which returns both the referenced column in the lookup, as well as the identifier of the value. So if you have a column named 'Department' of type lookup to another list 'Departments', and we know that the value that you want to use as the default is 'Sales', we can use a LookUp function if the column only allows single selection:

If(
    EditForm1.Mode = FormMode.New,
    LookUp(
        Choices(MyListName.Department),
        Value = "Sales"),
    Parent.Default)

Likewise, if the column supports multiple selection, then you'd use a Filter expression on the possible choices to define the default selected values:

If(
    EditForm1.Mode = FormMode.New,
    Filter(
        Choices(MyListName.RelatedDepartments),
        Value = "Sales" Or Value = "Human Resources"),
    Parent.Default)

 

Hope this helps Smiley Happy

 

 

RT

7 REPLIES 7
Super User
Super User

Re: Default Dropdown Value Not Working?

Hi afoti,

 

Are you using a form with the SubmitForm() function, or a Patch() function to update SPO?

If the former, can you confirm what your Update: property value of the card holding the dropdown is?

If the latter, or some other method, can you include the formula you're using and perhaps some screenshots?

 

Kind regards,

 

RT

Highlighted
afoti
Level: Powered On

Re: Default Dropdown Value Not Working?

Hi Russel,

 

I'm using the SubmitForm() function. 

 

The Update property on the card reads as "Dropdown.Selected".

 

Thanks,
Andrew

Super User
Super User

Re: Default Dropdown Value Not Working?

Hi Andrew,

 

Not sure what's happening on your side - seems to be working on my side, maybe I'm doing something different to what you've explained...

 

If the SharePoint choice column you're referring to has a Default set on the column settings, then not having a value for this field will result in the default being applied to the new row of data.

If you set the default on the card to a colour other than the column default, then the card default gets saved.

 

I created a choice column called Colours in SPO with three colour choices and loaded an Edit form and set it's default mode to New.

I set the Default value of the card to 

If(Form1.Mode=New, {
'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
Value:"Red"}, ThisItem.Colours)

I then set the choice control Default property to Default.Parent

 

If I reset the form and submit, it saves the Red value to the list.  If I set the value to something else, it saves that value.

So I'm not sure what, if anything, is different here...

choicedefault.PNG

 

Are you perhaps using a different control for the choices column?

 

Kind regards,


RT

 

 

Super User
Super User

Re: Default Dropdown Value Not Working?

Hi Andrew,

 

Not sure what's happening on your side - seems to be working on my side, maybe I'm doing something different to what you've explained...

 

If the SharePoint choice column you're referring to has a Default set on the column settings, then not having a value for this field will result in the default being applied to the new row of data.

If you set the default on the card to a colour other than the column default, then the card default gets saved.

 

I created a choice column called Colours in SPO with three colour choices and loaded an Edit form and set it's default mode to New.

I set the Default value of the card to 

If(Form1.Mode=New, {
'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
Value:"Red"}, ThisItem.Colours)

I then set the choice control Default property to Default.Parent

 

If I reset the form and submit, it saves the Red value to the list.  If I set the value to something else, it saves that value.

So I'm not sure what, if anything, is different here...

choicedefault.PNG

 

Are you perhaps using a different control for the choices column?

 

Kind regards,


RT

 

 

afoti
Level: Powered On

Re: Default Dropdown Value Not Working?

Hi Russel,

 

Thanks for your assistance with this. Now I think about it, the difference might be that my dropdown is referencing a "Lookup" column (which is in turn referencing another SharePoint list) instead of a standard "Choice" column. Do you know if it is supposed to work with a "Lookup" column or if there is another method I could use?

 

Thanks,

Andrew

Super User
Super User

Re: Default Dropdown Value Not Working?

Hi Andrew,

 

Check out this blog by Carlos Figuera, there is a section for Lookup column defaults.

Herewith the excerpt, but give the blog a read, it's great for various complex column types;

 

Lookup columns

Those are columns for which the user can select a value from another table. This time, using the value only is not enough - it's possible that there are multiple items in the table that is being looked up that have the same value for the referenced column, so we also need to specify the Id property of those values. The best way to retrieve it is to use the Choices function, which returns both the referenced column in the lookup, as well as the identifier of the value. So if you have a column named 'Department' of type lookup to another list 'Departments', and we know that the value that you want to use as the default is 'Sales', we can use a LookUp function if the column only allows single selection:

If(
    EditForm1.Mode = FormMode.New,
    LookUp(
        Choices(MyListName.Department),
        Value = "Sales"),
    Parent.Default)

Likewise, if the column supports multiple selection, then you'd use a Filter expression on the possible choices to define the default selected values:

If(
    EditForm1.Mode = FormMode.New,
    Filter(
        Choices(MyListName.RelatedDepartments),
        Value = "Sales" Or Value = "Human Resources"),
    Parent.Default)

 

Hope this helps Smiley Happy

 

 

RT

afoti
Level: Powered On

Re: Default Dropdown Value Not Working?

Worked perfectly, thanks heaps for your help Russel Smiley Happy

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 131 members 4,294 guests
Please welcome our newest community members: