Skip to main content

Notifications

Microsoft Dynamics 365 | Integration, Dataverse...
Answered

Hide/Show values in optionSet?

Posted on by 95

Hi All,

I need to hide/show values in an option set based on other fields. I am able to hide the options no problem using:

formContext.getControl("controlname").removeOption(100000002)

However, when I try use the formContext.getControl("controlname").addOption(100000002) to show the value again I get the following error when stepping through the code: Uncaught UciError: Required Parameter is null or undefined: optionSetItem.value

Based on the Microsoft Documentation don't see any parameters to add (https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/controls/addoption).

Am I missing something?

  • mykedeabreu Profile Picture
    mykedeabreu 95 on at
    RE: Hide/Show values in optionSet?

    Thanks Mehdi! You always seem to save my day! Appreciate it.

    I did not read close enough to see it required an object not value.

  • Verified answer
    meelamri Profile Picture
    meelamri 13,204 User Group Leader on at
    RE: Hide/Show values in optionSet?

    Hi,

    you need to add an object, not a number.

    Example:

    formContext.getControl("controlname").addOption({value:100000002,text:'OptionText'});

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans