powerapps

PowerApps Set DataCardValue of a DropDown to a TextBox value


I'm totally new to PowerApps. The app was created based on a SharePoint List. This specific field type is a dropdown with choices, and one of the choices is 'Other'. When the user selects 'Other' and enter value in a TextBox and hit Submit, the TextBox value should be saved to the List. If any other choices are selected in the dropdown, it should use the selected value.

I tried to set TextInput.Text in DataCard.Update() but it won't take it. It throws error "Expected Record Value".

enter image description here


Solution

  • Having an option worded "other" does not mean that any text can be saved to the Choice field in SharePoint. Go to the list settings and edit the column.

    If you want to allow free text in a SharePoint Choice field, you need to tick the option to Allow 'Fill-in' choices in the column definition in SharePoint. Otherwise, the free text entry will not be permitted.

    enter image description here

    With that in place, you can then create an IF statement in the Update property, like

    If(DataCardValue39.Selected.Value = "Other", TextInput3.Text, DataCardValue39.Selected)
    

    By the way, things will be a lot easier if you give your controls meaningful names instead of DataCardValue39.

    Edit: if that still does not help with the control in PowerApps, consider using a SharePoint text field instead of a Choice field for storage and a PowerApps dropdown + text input for the user interface in PowerApps. That way you have the ease of use of a dropdown for known values and the option for free text if required.