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

Auto set dropdown values on based of condition

I am using SharePoint list as datasource for Power App. Whenever the form is loading, I want to select value for dropdown Break Lights to be set automatically on based of condition (Yes / No / NA). 

 

2018-07-26 13_35_38-Window.png

So I am using below piece of code which unfortunately giving me an error.

2018-07-26 13_42_49-Window.png

 

 

Any suggestions, how this can be accomplished?

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Auto set dropdown values on based of condition

Hi @adminNQCranes,

 

Could you please share a bit more about the Brake Lights column within your SP list?

Is it a Choice type column within your SP list?

Further, do you want to auto-select a value for Brake Lights drop down based on the selected value within Dash Lights drop down?

 

I suppose that the Brake Lights column is a choice type column within your SP list, and you want to auto-select a value for Brake Lights drop down based on the selected value within Dash Lights drop down, is it true?

 

The error message told that the Property is required to provide a Record value, but you provided a Text value.

 

I have made a test on my side, please take a try with the following workaround:1.JPG

Note: The available values for the Brake Lights column are Red, Yellow and Blue. The availables values for the Dash Lights column are Yes, No and N/A. When you select Yes within Dash Lights drop down, the Brake Light drop down was set to Blue automatically, when select No within Dash Lights drop down, the Brake Light drop down was set to Red automatically, and so on.

 

  • Unlock the Brake Lights Data card control.
  • Within the Brake Lights Data card, set the DefaultSelectedItems property of the Combo box control to following formula:
If(
   DataCardValue2.Selected.Value="Yes",
   {'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
     Id: 0,
     Value: "Blue"  /*Type the value that you want to assign to this Combo box control*/
   },
   DataCardValue2.Selected.Value="No",
   {'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
     Id: 0,
     Value: "Red"
   },
   DataCardValue2.Selected.Value="N/A",
   {'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
     Id: 0,
     Value: "Yellow"
   },
   DataCardValue2.Selected.Value="",
   Parent.Default
)

Note: The DataCardValues2 represents the Combo box control within the Dash Lights Data card control.

 

The GIF image as below:Test1.gif

 

 

 

Please also check and see if the following thread would help in your scenario:

https://powerusers.microsoft.com/t5/General-Discussion/Dropdown-default-value/m-p/135191#M46842

 

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
1 REPLY 1
Community Support Team
Community Support Team

Re: Auto set dropdown values on based of condition

Hi @adminNQCranes,

 

Could you please share a bit more about the Brake Lights column within your SP list?

Is it a Choice type column within your SP list?

Further, do you want to auto-select a value for Brake Lights drop down based on the selected value within Dash Lights drop down?

 

I suppose that the Brake Lights column is a choice type column within your SP list, and you want to auto-select a value for Brake Lights drop down based on the selected value within Dash Lights drop down, is it true?

 

The error message told that the Property is required to provide a Record value, but you provided a Text value.

 

I have made a test on my side, please take a try with the following workaround:1.JPG

Note: The available values for the Brake Lights column are Red, Yellow and Blue. The availables values for the Dash Lights column are Yes, No and N/A. When you select Yes within Dash Lights drop down, the Brake Light drop down was set to Blue automatically, when select No within Dash Lights drop down, the Brake Light drop down was set to Red automatically, and so on.

 

  • Unlock the Brake Lights Data card control.
  • Within the Brake Lights Data card, set the DefaultSelectedItems property of the Combo box control to following formula:
If(
   DataCardValue2.Selected.Value="Yes",
   {'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
     Id: 0,
     Value: "Blue"  /*Type the value that you want to assign to this Combo box control*/
   },
   DataCardValue2.Selected.Value="No",
   {'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
     Id: 0,
     Value: "Red"
   },
   DataCardValue2.Selected.Value="N/A",
   {'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
     Id: 0,
     Value: "Yellow"
   },
   DataCardValue2.Selected.Value="",
   Parent.Default
)

Note: The DataCardValues2 represents the Combo box control within the Dash Lights Data card control.

 

The GIF image as below:Test1.gif

 

 

 

Please also check and see if the following thread would help in your scenario:

https://powerusers.microsoft.com/t5/General-Discussion/Dropdown-default-value/m-p/135191#M46842

 

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.