OptionSet fields and Javascript – Dynamics CRM

In order to get and set values in an OptionSet field in JavaScript, use the code below:

// Get Option Set
var Option_Set = Xrm.Page.data.entity.attributes.get("FieldName");
// Get Option Set / Selected Option
var OptionSet_Selcted_Option = Xrm.Page.data.entity.attributes.get("FieldName").getValue();
// Get Option Set / Options
var OptionSet_Options = Xrm.Page.data.entity.attributes.get("FieldName").getOptions();
// Get Option Set / Label text
var OptionSet_Label_Text = Xrm.Page.data.entity.attributes.get("FieldName").getText();

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s