cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MD2409_
Helper I
Helper I

Default Value for Field Type "DataCardValue"

Hi,

using the field Type DataCardValue in a existing app. But how i could define a default value for this? All inserts i try are not accepted.... A Howto by GUI or Code is interesting.

 

MD2409__0-1638001657562.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-xiaochen-msft
Community Support
Community Support

Hi @MD2409_ ,

 

I did a test for you.

I have a yes/no column in dataverse.

vxiaochenmsft_0-1638342915943.png

This is my combo box Items property :

vxiaochenmsft_1-1638342951488.png

Choices(TestL12.Test_Yes_No)

//TestL12 is the name of my table

 

Set combo box control's DefaultSelectedItems property to:

LookUp(Choices(TestL12.Test_Yes_No),Value='Test_Yes_No (TestL12)'.Yes)

 

Best Regards,

Wearsky

 

View solution in original post

8 REPLIES 8
AmDev
Super User
Super User

Hi @MD2409_ 

 

This appears to be a combobox control - should be at the top of the properties pane you have shown in your post. A combobox uses a table for its items and the selection is a record from that table.

 

'Datacardvalue' is a name that Power Apps automatically assigns to controls (in this case a combobox) within 'datacards', within a form.

 

What type of column is this combobox connected to? - Assuming it is a choice field?

 

The 'defaultselecteditems' in the datacardvalue should be 'ThisItem.YourColumnName'.

 

For info - by default, when you set up a form, it will show the following in 'defaultselecteditems' for the control (i.e. datacardvalue): 'Parent.Default'. By this, it is referring to the parent control, the datacard that it sits within and then the default property of the datacard is 'ThisItem.YourColumnName'. This has the same result and displays the current item for this field from your backend data.

 

If there is any doubt, the  easiest thing to do if you are not doing anything too specific is to remove this field from the form, then simply re-add it. This will reset the Datacard and controls within back to their default code.

 

Hope this helps - Good Luck

Thx for your feedback, but it sound a bit complicated.
Id just like to know, what i need to insert in this field to set the default value for this field?
The options are Yes or No for this field but the system do not accept this in any way i try...

zmansuri
Super User
Super User

Set the DefaultSelectedItems:

["Yes"]

 

Hi @MD2409_ 

 

It depends what you want your default to be:

 

  • If it's the value in your backend data source for the currently selected item it's: 'ThisItem.YourColumnName'
  • If you want to leave it blank, just leave it empty
  • If you want Yes go for ["yes"] 
  • If you want No go for ["No"]

 

 

Hi, 

the actual accpeted value is ThisItem.YourColumnName when i change it to ["yes"] i got again a error message.
The field behind in dataverse is a Yes /No Boolean column.

Hi @MD2409_ 

 

Glad that worked out for you. Yes a Boolean will not accept ["yes"].

 

If my posts helped you, please consider accepting as a solution.

 

Many thanks and good luck with the rest of your build

???
As mentioned it does not work as recommendet !

v-xiaochen-msft
Community Support
Community Support

Hi @MD2409_ ,

 

I did a test for you.

I have a yes/no column in dataverse.

vxiaochenmsft_0-1638342915943.png

This is my combo box Items property :

vxiaochenmsft_1-1638342951488.png

Choices(TestL12.Test_Yes_No)

//TestL12 is the name of my table

 

Set combo box control's DefaultSelectedItems property to:

LookUp(Choices(TestL12.Test_Yes_No),Value='Test_Yes_No (TestL12)'.Yes)

 

Best Regards,

Wearsky

 

Helpful resources

Top Solution Authors
Top Kudoed Authors
Users online (4,388)