In this article I am going to provide JScript syntax’s to use in projects.

Refer my previous article on configuring Multi Select Option set fields.

// Read the values
var branches = Xrm.Page.getAttribute(“new_branches”).getValue();
Xrm.Utility.alertDialog(“Branches – ” + branches, null);

// Set the values (i.e., Hyderabad,Chennai)
Xrm.Page.getAttribute(“new_branches”).setValue([100000000, 100000001]);

// Determine if the option is selected

// Non-IE Browser
var isCitySelected = Xrm.Page.getAttribute(“new_branches”).getValue().includes(100000000);

// IE Browser

var isCitySelected = Xrm.Page.getAttribute(“new_branches”).getValue().indexOf(100000000)>=0;

Xrm.Utility.alertDialog(“Is City Selected – ” + isCitySelected, null);

// Clear the values
Xrm.Page.getAttribute(“new_branches”).setValue(null);

Create a web resource with these syntax’s and map to the form.

JScript - Multi select option set

🙂

Advertisements
Advertisements

4 responses to “D365 – Multi Select Option set JScript Syntax”

  1. Chris Groh Avatar
    Chris Groh

    Array.includes isn’t available in IE11. An alternative might be getValue().indexOf(100000000) >= 0.

    1. Rajeev Pentyala Avatar

      Thanks for pointing Chris.

  2. elblogdecrm Avatar

    The IE browser does not support the includes function, it gives an exception
    var isCitySelected = Xrm.Page.getAttribute(“new_branches”).getValue().includes(100000000);

Leave a comment