Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Multi-Select Option Set - clearOptions() NOT clearing selected options

Posted on by Microsoft Employee

I have JavaScript onChange of a field that needs to trigger another field, a multi-select option set, to clear any/all selected options.

I cannot get it to work using: formContext.getControl("multiselectfieldname").clearOptions();

Anyone else experiencing this issue?

Any suggestions / help would help!!

*This post is locked for comments

  • necsa Profile Picture
    necsa 3,455 on at
    RE: Multi-Select Option Set - clearOptions() NOT clearing selected options

    Hi,

    your link is broken not working

  • Suggested answer
    Premz Profile Picture
    Premz 50 on at
    RE: Multi-Select Option Set - clearOptions() NOT clearing selected options

    Yes. Agreed. To clear the selected values setting it to null is the right way.

  • erhan.keskin Profile Picture
    erhan.keskin 2,247 on at
    RE: Multi-Select Option Set - clearOptions() NOT clearing selected options

    Hi,

    clearOptions() is a method to clear the options of the OptionSet field on the form, by that you can re-build your options on the form dynamically.

    However, the values selected by users are different. If you need to clear the selected values, all of them, then set the field to Null.

    Regards,

  • Premz Profile Picture
    Premz 50 on at
    RE: Multi-Select Option Set - clearOptions() NOT clearing selected options

    Works in version 9.1

    //set the mutli select option set to blank.

    formContext.getControl("fieldname").clearOptions();

    Check this out.

    https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/controls/clearoptions

  • Suggested answer
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,074 on at
    RE: Multi-Select Option Set - clearOptions() NOT clearing selected options

    Hi,

    You can set the attribute value to null to clear the muti-select options.

    Please try the code below.

    Xrm.Page.getAttribute("multiselectfieldname").setValue(null);

    Hope this helps.

  • Suggested answer
    Arpit Shrivastava Profile Picture
    Arpit Shrivastava 7,518 User Group Leader on at
    RE: Multi-Select Option Set - clearOptions() NOT clearing selected options

    Hi,

    Check this:

    howtomscrm.com/.../dynamics-365-v9-0-set-multi-select-option-set-values-using-jscript.html

    Set value null instead of using method clear().

    formContext.getAttribute("new_multiselect").setValue(null);

    Hope it helps.

    -Arpit

  • Manju Gurjar Profile Picture
    Manju Gurjar 60 on at
    RE: Multi-Select Option Set - clearOptions() NOT clearing selected options

    Hi,

    Try using below syntax.

    formContext.getAttribute("new_multiselect").setValue(null);

    }

    Thanks ,

  • Suggested answer
    Alex Fun Wei Jie Profile Picture
    Alex Fun Wei Jie 33,626 on at
    RE: Multi-Select Option Set - clearOptions() NOT clearing selected options

    Hi,

    you need to use setValue(null) to remove the selected options. Refer below article for more informations.

    www.itaintboring.com/.../dynamics-365-v9-multi-select-option-set

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!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans