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  :

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: \n\n”;
        $(controlName).find(‘option’).first().nextAll().each
        (function () {
            optionSetValues += ‘<div>’ + ‘Value: ‘ + $(this).attr(‘value’) + ‘,Title: ‘ + $(this).attr(‘title’) + ‘</div>’;
        }
        );
    }
    optionSetAttributes += ‘<div>’ + optionSetValues + ‘</div>’;
});

var htmlString = ‘<div style= “overflow:always”>’ + optionSetAttributes + ‘</div>’;
$(“#processControlCollapsibleArea”).after(htmlString);

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

You will get following new page:

image

Just do Ctrl+ C and you are done!

Hope it helps!

Advertisement

3 thoughts on “Read Option set Text/Value at one go CRM 2013

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 )

Facebook photo

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

Connecting to %s