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: \n\n”;
        (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 new page:


Just do Ctrl+ C and you are done!

Hope it helps!


Get Hidden field names on form: Dynamics CRM 2011/2013

This script will alert all hidden field names on form:

var attributes =;

var hiddenAttributes = ”;

Xrm.Page.ui.controls.forEach(function (control, index)

{ if (control.getVisible() == false) { hiddenAttributes += control.getName() + ‘,’;


} );


Change color for text fields : Dynamics CRM 2013

Sometimes we get requirement to change the forecolor for some fields in Dynamics CRM 2013 in order to highlight them in different color. So we implemented following script:

You can add the scripts on-load or based on some condition.

For changing color during field is non-selected:

//Setting red color


Now Field looks like this:


In order to change color during field is typed:

//Setting color blue during typing of field

$(‘#fieldname_i’).css(‘color’, color);

UI will look like below now:


Note: This is unsupported script and may break in future if Microsoft changes something.

Hope it helps!

Check this out

Trying to Learn Dynamics CRM: Download!

Learn Dynamics CRM App on Google Play store