Read Option set Text/Value at one go CRM 2013


Often we have requirement to read option set Text/Value quickly, I wrote a script to quickly read all option sets on a form

Go to Google chrome console(Press F12 in Chrome), select the option Console as per screen, Note that contentIframe0 is selected :


and run following script on your form :

var attributes =;

var optionSetAttributes = ”;
var optionSetValues = ”;
Xrm.Page.ui.controls.forEach(function (control, index) {
if (control.getControlType() == ‘optionset’) {
optionSetValues = ”;
var controlName = “#” + control.getName() + “_i”;
optionSetValues += control.getName() + ” option set values below: nn”;
(function () {
optionSetValues += ‘<div>’ + ‘Value: ‘ + $(this).attr(‘value’) + ‘,Title: ‘ + $(this).attr(‘title’) + ‘</div>’;
optionSetAttributes += ‘<div>’ + optionSetValues + ‘</div>’;

var htmlString = ‘<div style= “overflow:always”>’ + optionSetAttributes + ‘</div>’;

var w =“Surprise”, “#”);
var d =;

You will get following…

View original post 13 more words

Author: Nishant Rana

I love working in and sharing everything about Microsoft.NET technology !

Please share your thoughts

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

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.