Advertisements
Home > Dynamics 365 > D365 – Multi Select Option set JScript Syntax

D365 – Multi Select Option set JScript Syntax

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
  1. Chris Groh
    November 22, 2017 at 12:49 AM

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

  2. November 24, 2017 at 1:15 PM

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

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: