π― Power Apps Tip: Disable Choice Field Based on Text Field Value in SharePoint Custom Form
π― Power Apps Tip: Disable Choice Field Based on Text Field Value in SharePoint Custom Form
Author: powerapps fargo
Scenario: You’re customizing a SharePoint list form using Power Apps. You want the form behavior to be dynamic — if one field is empty, another should reset and become unselectable.
Let’s look at a real-world example to implement this.
π§ Use Case
You have a SharePoint list called codewarrior with the following two columns:
-
openai– Single line of text -
gpt– Choice column (dropdown)
π§ Business Rule
If the
openaifield is blank, thegptdropdown should:
Be cleared
Be disabled (grayed out)
If openai has text, the gpt field becomes active again.
π ️ Step-by-Step Guide
Let’s walk through how to achieve this in a Power Apps customized SharePoint form.
✅ Step 1: Open the Power Apps Form Customization
-
Navigate to your SharePoint list
codewarrior -
From the top ribbon, click:
-
Integrate → Power Apps → Customize forms
-
-
Power Apps Studio will launch in a new tab with your list form
✅ Step 2: Rename Controls for Clarity
In Power Apps Studio:
-
In the left pane (Tree View), expand:
-
FormScreen1→SharePointForm1
-
-
Rename your key controls:
-
Select the text input inside the
openaicard → rename it totxtOpenAI -
Select the dropdown inside the
gptcard → rename it todrpGPT
-
π Renaming helps maintain clean and readable formulas.
✅ Step 3: Make gpt Blank When openai Is Empty
-
Select the
drpGPTcontrol (choice dropdown) -
In the top formula bar, set the
DefaultSelectedItemsproperty to:
If(
IsBlank(txtOpenAI.Text),
Blank(),
LookUp(Choices(codewarrior.gpt), Value = ThisItem.gpt.Value)
)
✅ This ensures that the gpt field is cleared if the user didn’t type anything in openai.
✅ Step 4: Disable gpt When openai Is Blank
-
Keep
drpGPTselected -
In the formula bar, set the
DisplayModeproperty to:
If(
IsBlank(txtOpenAI.Text),
DisplayMode.Disabled,
DisplayMode.Edit
)
✅ This disables the dropdown, preventing users from selecting a value until openai is filled.
✅ Step 5: Auto-Reset gpt When openai is Cleared
-
Select the
txtOpenAItext input -
Go to the
OnChangeproperty -
Add this line:
If(
IsBlank(txtOpenAI.Text),
Reset(drpGPT)
)
✅ Now, when a user deletes the text from openai, the gpt choice field will automatically reset to blank.
✅ Step 6: Save and Publish the Custom Form
-
Click File → Save
-
Then click Publish to SharePoint
-
Go back to your SharePoint list and test the form
π§ͺ Result: Intelligent Field Behavior
openai Field |
gpt Dropdown Behavior |
|---|---|
| Blank | Disabled + Cleared |
| Has Text | Enabled + Shows saved value |
✅ Optional Enhancement
You could also display a tooltip or message when the dropdown is disabled:
Tooltip = If(IsBlank(txtOpenAI.Text), "Please fill the 'openai' field first", "")
π Final Thoughts
This solution shows how you can create smarter Power Apps forms by linking field behavior together. This reduces user errors and ensures data consistency without writing any code outside Power Apps.
Have more SharePoint + Power Apps automation ideas? Drop them in the comments or reach out!
Comments
Post a Comment