Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Answered

Hide/Show values in optionSet?

(1) ShareShare
ReportReport
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,206 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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey Pt 2

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,540 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans