cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Veblitz
Helper III
Helper III

To set sharepoint dropdown Lookup Field type default blank

I have dropdown lookup field in my Add form where i have used patch functions to add new entries,so i need to perform validation to check if  dropdown value is blank in onchange property or not so that user cant submit the form.however i set the default value empty but then its fetching the lookup values entries.

 

But below is not working since by default dropdown values is been set,not sure how to add blank entry as default choice to ensure whether this below condition would work

 

onchange property of dropdown(i.e lookup values) contains below condition

 

updatecontext({dropdownclientvalid:Not(IsBlank(dropdownclient.SelectedText))})

 

Button display mode: if(dropdownclientvalid,DisplayMode.Edit,DisplayMode.Disabled)

 

Kindly help

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@Veblitz 

So you should ask yourself if you need the entire record of the list.  When you set the Items to your datasource, it will contain a table of all the records in your list and all of the columns in the list.

 

So, if you ONLY want a table of records with Title, then your formula on the Items property can be: yourList.Title

Then you can actually add a blank value to that with the following formula:

Ungroup(
    Table(
        {Items: Table({Title:""})},
        {Items: yourList.Title}
    ),
    "Items"
)

This will result in a table of Titles where the first record is a blank value.

 

IF you need all the columns of the record (i.e.  Items property set to yourList), then the following formula would give you a blank in the list:

Ungroup(
    Table(
        {Items: Table(Patch(Defaults(yourList), {Title:""}))},
        {Items: yourList}
    ),
    "Items"
)

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

9 REPLIES 9
RandyHayes
Super User
Super User

@Veblitz 

Can you explain more about what you mean by "you have a form" and "you use patch to add entries"?

Are you using an EditForm or is this a "form" of your own creation?

Also, what is the Items property of your dropdown control?

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Hi Randy,

I have my own custom form and dropdown items property is set to sharepoint list name client  and field value is Title ,so items are displaying in the dropdown. But my ask is that we need to set empty value as default value in the dropdown. I played around in the dropdown property and found allowempty selection true but then it looks we need to reset manually otherwise default value is not getting reverted to blank value, furthering my query is it possible to check for required field validation for dropdown field.Thanks.

RandyHayes
Super User
Super User

@Veblitz 
Okay, so if this is a custom form, then let's start with the button part.

Your DisplayMode property should be:  If(!IsBlank(dropdownclient.Selected.Title), Edit, Disabled)

You don't need to set variables for this.

 

For the Dropdown to be empty by default, then you need to put Blank() in the Default property of the dropdown. And make sure you have allow empty selection set to true.

 

Now, let's explore what you mean by "not getting reverted to blank".  Can you elaborate a little on this more?

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Sure, when I play my app I note dropdown value for dropdown client appears as blank value initially as per your above steps ,later when I choose some values  ,blank value is not listed as one of the choices in our dropdown options.

 

Lastly, I explored that we need to reselect the same value which we choose in our dropdown i.e client1  option I selected and again when I choose client1 options from my listed dropdown values then its getting reset as Blank in my dropdown then we are able to achieve the required field validation as part of button click.(as per your code).

 

But do we have any workaround to overcome the above issue .Thank you

RandyHayes
Super User
Super User

@Veblitz 

Yes, the allow blank selection simply allows the dropdown to have a blank selection.  It does not add a blank to the list.  To make it blank, if you dropdown the selections and click on the one that is selected, the dropdown will go blank.

If you want a blank selection in the list, then I need to know what your Items property of the dropdown is.

I assume this is the issue you are referring to.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Yup correct. They have only basic configuration lets say my item property maps to sharepoint list and i followed below steps mentioned below, Finally, I am just exploring the scenario at basic level to understand the dropdown functionality for listing blank values in the selected options.

Below are the dropdown configurations/Items settings :

1. select->insert  dropdown to my screen

2.Under items properties  choosed sharepoint list Client,selected value as Title column

3.I enabled allowempty selection true

 

further,i did not change any existing settings to my dropdown properties.Thanks

RandyHayes
Super User
Super User

@Veblitz 

So you should ask yourself if you need the entire record of the list.  When you set the Items to your datasource, it will contain a table of all the records in your list and all of the columns in the list.

 

So, if you ONLY want a table of records with Title, then your formula on the Items property can be: yourList.Title

Then you can actually add a blank value to that with the following formula:

Ungroup(
    Table(
        {Items: Table({Title:""})},
        {Items: yourList.Title}
    ),
    "Items"
)

This will result in a table of Titles where the first record is a blank value.

 

IF you need all the columns of the record (i.e.  Items property set to yourList), then the following formula would give you a blank in the list:

Ungroup(
    Table(
        {Items: Table(Patch(Defaults(yourList), {Title:""}))},
        {Items: yourList}
    ),
    "Items"
)

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

😎 .Awesome... I would try the same and keep you posted if any issues. Thanks a lot Randy for your detailed guidance and great help.

Many Thanks Randy.  👍 

I am able to add Blank choice in my selection list of dropdown control by using your above code inputs

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (1,430)