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

How to connect a text field to a drop down with predefined values?

I have a drop down with some values, one is "Other".

How can I add a text field for entering an other value when the "Other" value is selected in the drop down?

The text value should be stored in the same field as where the predefined values are stored.

1 ACCEPTED SOLUTION

Accepted Solutions

@RemcodeB 

To do this I would add some code to the Default properties of both Dropdown1 and TextInput1.  Continuing my previous example: put this code in the Default property of TextInput1.

 

If(
    Not(ThisItem.Color in ["Red","Black","Blue"]),
    ThisItem.Color,
    Blank()
)

 

Then put this code in the Default property of DropDown1.

 

If(
    ThisItem.Color in ["Red","Black","Blue"],
    ThisItem.Color,
    "Other"
)

 

I'll ask you to please test this solution for me and if it does not work I will setup a test again on my side.

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

7 REPLIES 7
mdevaney
Super User
Super User

@RemcodeB 

Here's a mini-tutorial I have made just for you.

 

#1 We start by creating an EditForm with a single Dropdown.  The field Color Selection is a Text field in Sharepoint so we must use the following code in the Items property to define the Choices.

 

dd1.PNG

 

#2 Click Other on the Dropdown

 

dd2.png

 

#3 Create a new TextInput within the same datacard as the Dropdown.  Use the following code in the Visible property to make the field show/hide when Other is selected/not selected.

 

dd3.PNG

 

#4 Finally, click on the datacard holding both the Dropdown and TextInput and put this code in the Update property.  When Other is selected the TextInput contents will be submitted to Sharepoint and otherwise the Dropdown contents will be submitted instead.

 

dd4.PNG

 

#5.  Create a button with the following code in the OnSelect property and then click it.  Your info will now be changed in Sharepoint.

 

SubmitForm(your_form_name);

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

This is exactly what I was looking for.

But now I have another question:

When I have entered another color like "Pink" and I reopen the Form in edit mode the Dropdown is empty and the Textinput is not displayed.

How can I display the "Other" values when reopening the Form in edit mode?

@RemcodeB 

To do this I would add some code to the Default properties of both Dropdown1 and TextInput1.  Continuing my previous example: put this code in the Default property of TextInput1.

 

If(
    Not(ThisItem.Color in ["Red","Black","Blue"]),
    ThisItem.Color,
    Blank()
)

 

Then put this code in the Default property of DropDown1.

 

If(
    ThisItem.Color in ["Red","Black","Blue"],
    ThisItem.Color,
    "Other"
)

 

I'll ask you to please test this solution for me and if it does not work I will setup a test again on my side.

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

I get errors when I try to implement your solution.

In my app I have a dropdown with Items = ["","Study","Holiday","Other"]

I have tried to adjust your solution:  

    Not(ThisItem.Color in ["Red","Black","Blue"]),

 to :

Not(ThisItem.'column name' in ["","Study","Holiday""Other"]),

The error message is "Expected operator."

I have copied your examples and only changed Color to 'column name' and substituted your values by my Item values.

So I do not see a missing operator (comma).

I have tried to add .Text after the column name but that did not solve the error.

@RemcodeB 

The issue appears to be the semi-colon ( ; ) I put at the end of each code block.  My corrected code is in the original post above.  Please remove the semi-colon and the error will go away.  I've made sure to test on my side.  Let me know if it works for you.

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

The semi-colon was the issue, now it works like a charm 😊

Thank you for all your quick responses, I have learnt a lot.

@RemcodeB 

You are very welcome.  Hopefully we can connect again soon.

Helpful resources

Announcements
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (1,467)