web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Disable an item in a C...
Power Apps
Answered

Disable an item in a Choice field using JavaScript in a Model driven app

(0) ShareShare
ReportReport
Posted on by 65

Hi all,

Is it possible to either disable an item in a Choice field so that it cannot be selected? Alternatively, (and perhaps even better) dynamically edit the choices by adding/removing items based on a condition? See my comment in the 'for loop' below.

Thanks for any and all suggestions.

function disablePTClassOfTravelChoice(executionContext) {
  var formContext = executionContext.getFormContext();
  var caseTypeText = formContext.getAttribute("kcw_casetype").getText();
  var choiceField = formContext.getControl("kcw_scopeptclassoftravel");

  var options = choiceField.getOptions();

  for (var i = 0; i < options.length; i++) {

      /*
      Test the value(label?) of the option and if it is the one we are looking for
      then either disable it as a valid option or better yet remove it from the
      list of options.
      */

  }
}
I have the same question (0)
  • Verified answer
    a33ik Profile Picture
    3,306 Most Valuable Professional on at

    Hello,

    Unfortunately, the OOB Optionset Dropdown doesn't allow you to disable items but you can dynamically add/remove items from the list. Check this post - https://www.crmcrate.com/javascript/how-to-add-remove-optionset-values-programmatically-in-dynamics-365-crm/

  • kcward55 Profile Picture
    65 on at

    Works perfectly. Thanks so much.

  • Suggested answer
    Mohith B Profile Picture
    2 on at

    But now there is a better way of doing it. We can hide the optionvalue directly from the optionset/Choice editor in the make.powerapps.com. With this way the value will not show on the UI using configuration without writing Javascript.

    Follow below steps
    Step 1: Navigate to https://make.powerapp.com
    Step 2: On the left navigation page click on Tables
    Step 3: Search and open desired table by clicking on it. (For Example: Account)
    Step 4: On the schema section click on "Columns"
    Step 5: On the list of columns search desired column with Data Type = "Choice".(For Example : Industry)
    Step 6: Now Edit the Column by clicking on the field name which opens a popup
    Step 7: Navigate to Choice section and select the value (For Example: Accounting) which you want to hide by clicking on "Additional Properties".
    Step 8: This would open a popup in that there is a checkbox called "Hidden". Enable that checkbox.
    Step 9: Click on Save.
    Step 10: Publish the table to reflect the changes.
    Step 11: Navigate back to Application and check the value which we are hiding in the optionset field on the form it will not longer be visible.

    Capture.PNG

    Your file is currently under scan for potential threats. Please wait while we review it for any viruses or malicious content.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard