cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
afoti
Frequent Visitor

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
Microsoft
Microsoft

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 🙂

 

 

RT

View solution in original post

7 REPLIES 7
Microsoft
Microsoft

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

afoti
Frequent Visitor

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

Highlighted
Microsoft
Microsoft

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

 

 

Microsoft
Microsoft

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
Frequent Visitor

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

Microsoft
Microsoft

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 🙂

 

 

RT

View solution in original post

afoti
Frequent Visitor

Re: Default Dropdown Value Not Working?

Worked perfectly, thanks heaps for your help Russel Smiley Happy

Helpful resources

Announcements
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Power Platform 2020 release wave 1 plan

Power Platform 2020 release wave 1 plan

Features releasing from April 2020 through September 2020

Top Solution Authors
Top Kudoed Authors
Users online (2,328)