Read Option set Text/Value at one go CRM 2013

MSDYNAMICSBLOG BY DEEPESH

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 :

image

and run following script on your form :

var attributes = Xrm.Page.data.entity.attributes.get();

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”;
$(controlName).find(‘option’).first().nextAll().each
(function () {
optionSetValues += ‘

’ + ‘Value: ‘ + $(this).attr(‘value’) + ‘,Title: ‘ + $(this).attr(‘title’) + ‘
’;
}
);
}
optionSetAttributes += ‘
’ + optionSetValues + ‘
’;
});

var htmlString = ‘

’ + optionSetAttributes + ‘
’;
$(“#processControlCollapsibleArea”).after(htmlString);

var w = window.open(“Surprise”, “#”);
var d = w.document.open();
d.write(htmlString);
d.close();

You will get following…

View original post 13 more words

Author: Nishant Rana

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

Share your thoughts

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