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

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

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

(0) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • Suggested answer
    Alex Fun Wei Jie Profile Picture
    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

  • Manju Gurjar Profile Picture
    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
    Arpit Shrivastava Profile Picture
    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

  • Suggested answer
    Nithya Gopinath Profile Picture
    17,078 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.

  • Premz Profile Picture
    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

  • erhan.keskin Profile Picture
    2,253 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,

  • Suggested answer
    Premz Profile Picture
    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.

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

    Hi,

    your link is broken not working

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#2
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans