<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>MSCRM Blogger &#187; script</title>
	<atom:link href="http://mscrmblogger.com/tag/script/feed/" rel="self" type="application/rss+xml" />
	<link>http://mscrmblogger.com</link>
	<description>Achieving it all with Microsoft Dynamics CRM™</description>
	<lastBuildDate>Thu, 10 May 2012 20:24:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Lookup data from a related entity (Lookup) using JScript and the XrmServiceToolkit</title>
		<link>http://mscrmblogger.com/2012/05/10/lookup-data-from-a-related-entity-lookup-using-jscript-and-the-xrmservicetoolkit/</link>
		<comments>http://mscrmblogger.com/2012/05/10/lookup-data-from-a-related-entity-lookup-using-jscript-and-the-xrmservicetoolkit/#comments</comments>
		<pubDate>Thu, 10 May 2012 20:22:56 +0000</pubDate>
		<dc:creator>Carlton Colter</dc:creator>
				<category><![CDATA[API-SDK]]></category>
		<category><![CDATA[Extensions]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Web Resources]]></category>
		<category><![CDATA[CodePlex]]></category>
		<category><![CDATA[crm]]></category>
		<category><![CDATA[crm 2011]]></category>
		<category><![CDATA[CRM Online]]></category>
		<category><![CDATA[crm sdk]]></category>
		<category><![CDATA[crm2011]]></category>
		<category><![CDATA[field]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jscript]]></category>
		<category><![CDATA[lookup]]></category>
		<category><![CDATA[Microsoft Dynamics CRM 2011]]></category>
		<category><![CDATA[onchange]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[Web Resource]]></category>
		<category><![CDATA[XrmServiceToolkit]]></category>

		<guid isPermaLink="false">http://mscrmblogger.com/?p=1007</guid>
		<description><![CDATA[Lookup information from a related entity using the XrmServiceToolkit or just the REST endpoint.]]></description>
			<content:encoded><![CDATA[<p>Do you need the value from a related entity, like a lookup?  I had written this for CRM 4 a while back, and people use it, but I occasionally get questions about looking up other values in CRM.  This bit of code will help you find those values on a related object.  Below are two options to do this.  Option 1: using the REST SDK and JSON2, and then Option 2: using Jaimie Ji&#8217;s <a href="http://xrmservicetoolkit.codeplex.com/" target="_blank">XRM Service Toolkit</a>.</p>
<p>Jaimie Ji&#8217;s <a href="http://xrmservicetoolkit.codeplex.com/" target="_blank">XRM Service Toolkit</a> provides a comprehensive set of JScript libraries for interacting with the SOAP and REST SDK through JavaScript.  While Option 1 in this particular use case is fairly simple, when you start needing to do more advanced things, you may want to look at using that kit.  It is fairly comprehensive and he keeps it up to date.</p>
<h1>Option 1: Using the REST SDK and JSON2</h1>
<p>Using the REST SDK is great, and there are some really good examples in the CRM SDK help file.  Now in order to use the below code-block, you need to use JSON.</p>
<p>JSON, or JavaScript Object Notation, is a text format that is used to interchange data.  JSON2.js is a lightweight javascript that convert the strings to javascript objects and vice-versa.  The CRM REST SDK can return data in JSON format.</p>
<p>To get the code for JSON2, you can go <a href="https://github.com/douglascrockford/JSON-js" target="_blank">here</a>.  You will need to embed this code into your javascript file or include json2.js along with the code below.  Without it, you will not be able to parse the data properly, and the code below uses the JSON library in json2.js.</p>
<p>Ok, below we have 3 functions:</p>
<ul>
<li><b>getServerUrl</b> :  which gets the server URL &#8211; taken from the <a href="http://crmrestkit.codeplex.com/" target+"_blank">CrmRestKit</a></li>
<li><b>Lookup_Changed</b> : what you call when a lookup is changed</li>
<li><b>retrieveReqCallBack</b> : the callback function that performs any actions</li>
<li>
</li>
</ul>
<p>You would put Lookup_Changed in the change event of a lookup field and specify the attributes like one of the following:</p>
<ul>
<li>&#8216;contactid&#8217;,'Contact&#8217;,'contactlookup&#8217;</li>
<li>&#8216;contactid&#8217;,'Contact&#8217;,'contactlookup&#8217;,['Telephone1']</li>
<li>&#8216;contactid&#8217;,'Contact&#8217;,'contactlookup&#8217;,['Telephone1','FullName]</li>
</ul>
<p>Then you&#8217;d put your actions inside the retrieveReqCallBack.</p>
<pre name="code" class="javascript">
function getServerUrl() {
    // From CrmRestKit.js
    var localServerUrl = window.location.protocol + &quot;/&quot; + window.location.host;
    var context = parent.Xrm.Page.context;

    if (context.isOutlookClient() &amp;&amp; !context.isOutlookOnline()) {
        return localServerUrl;
    }
    else {
        var crmServerUrl = context.getServerUrl();
        crmServerUrl = crmServerUrl.replace(/^(http|https):\/\/([_a-zA-Z0-9\-\.]+)(:([0-9]{1,5}))?/, localServerUrl);
        crmServerUrl = crmServerUrl.replace(/\/$/, &quot;&quot;);
    }
    return crmServerUrl;
}

function Lookup_Changed(attributeName, entityName, callbackId, columns) {
    var serverUrl = Xrm.Page.context.getServerUrl();
    var ODataPath = serverUrl + &quot;/XRMServices/2011/OrganizationData.svc&quot;;

    var lookup = Xrm.Page.data.entity.attributes.get(attributeName).getValue();
    if (lookup===null) {
        return false;
    }

    var id = lookup[0].id;
    if (id == null) {
        return false;
    }

    var retrieveReq = new XMLHttpRequest();

    var url = ODataPath + &quot;/&quot;+entityName+&quot;Set(guid'&quot; + id + &quot;')&quot;;
    if (columns !== undefined &amp;&amp; columns !== null) {
        url = url + &quot;?$select=&quot; + columns.join(',');
    }

    retrieveReq.open(&quot;GET&quot;, url, true);
    retrieveReq.setRequestHeader(&quot;Accept&quot;, &quot;application/json&quot;);
    retrieveReq.setRequestHeader(&quot;Content-Type&quot;, &quot;application/json; charset=utf-8&quot;);
    retrieveReq.onreadystatechange = function () {
        if (this.readyState == 4 /* complete */) {
            if (this.status == 200) {
                var data;
                var jData;
                jData = JSON.parse(this.responseText);
                if (jData &amp;&amp; jData.d &amp;&amp; jData.d.results &amp;&amp; jData.d.results.length &gt; 0) {
                    data = jData.d.results[0];
                } else if (jData &amp;&amp; jData.d) {
                    data = jData.d;
                }

                if (data == null) {
                    return;
                }
                retrieveReqCallBack(callbackId, data);
            }
        }
    };
    retrieveReq.send();
    return true;
}

function retrieveReqCallBack(calltype, data) {
    var toLookup=function(data) {
        if (data==null || data==&quot;&quot; || (data.Id==null)) {
            return null;
        }

        var result=new Array();
        result[0] = {};
        result[0].id = data.Id;
        result[0].name = data.Name;
        result[0].entityType = data.LogicalName;
        return result;
    }

    switch (calltype) {
        case 'pricelookup':
            Xrm.Page.data.entity.attributes.get(&quot;new_pricecategorylookup&quot;).setValue(toLookup(c.new_pricecategorylookup);
            break;
        case 'contactlookup':
            Xrm.Page.data.entity.attributes.get(&quot;insp_poctelephonenumber&quot;).setValue(c.Telephone1);
            break;
        default:
            break;
    }
}
</pre>
<h1>Option 2: Using the XrmServiceToolkit with similar functions</h1>
<p>Ok, now let&#8217;s assume you are using the <a href="http://xrmservicetoolkit.codeplex.com/" target="_blank">XRM Service Toolkit</a>, and you want to do the same thing, using a Lookup_Changed function and the retrieveReqCallBack function.  Instead of embedding JSON and a method to get the server url, you can use the following:</p>
<pre name="code" class="javascript">
function Lookup_Changed(attributeName, entityName, callbackId, columns) {
    var lookup = Xrm.Page.data.entity.attributes.get(attributeName).getValue();
    if (lookup===null) {
        return false;
    }

    if (lookup[0].id == null) {
        return false;
    }

	XrmServiceToolkit.Rest.Retrieve(
        entityName,
        lookup[0].id,
        columns,
		null,
        function (result) {
            retrieveReqCallBack(callbackId, result);
        },
        function (error) {
            throw error;
        },
		true
    );
}

function retrieveReqCallBack(calltype, data) {
    var toLookup=function(data) {
        if (data==null || data==&quot;&quot; || (data.Id==null)) {
            return null;
        }

        var result=new Array();
        result[0] = {};
        result[0].id = data.Id;
        result[0].name = data.Name;
        result[0].entityType = data.LogicalName;
        return result;
    }

    switch (calltype) {
        case 'pricelookup':
            Xrm.Page.data.entity.attributes.get(&quot;new_pricecategorylookup&quot;).setValue(toLookup(c.new_pricecategorylookup);
            break;
        case 'contactlookup':
            Xrm.Page.data.entity.attributes.get(&quot;insp_poctelephonenumber&quot;).setValue(c.Telephone1);
            break;
        default:
            break;
    }
}
</pre>
<p>The <a href="http://xrmservicetoolkit.codeplex.com/" target="_blank">XRM Service Toolkit</a> does a lot, and I would suggest checking it out.</p>
]]></content:encoded>
			<wfw:commentRss>http://mscrmblogger.com/2012/05/10/lookup-data-from-a-related-entity-lookup-using-jscript-and-the-xrmservicetoolkit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CRM2011: Attachment Image Browser HTML Web Resource</title>
		<link>http://mscrmblogger.com/2012/03/31/imagebrowser-webresource/</link>
		<comments>http://mscrmblogger.com/2012/03/31/imagebrowser-webresource/#comments</comments>
		<pubDate>Sun, 01 Apr 2012 03:59:32 +0000</pubDate>
		<dc:creator>Carlton Colter</dc:creator>
				<category><![CDATA[Extensions]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Web Resources]]></category>
		<category><![CDATA[crm]]></category>
		<category><![CDATA[crm 2011]]></category>
		<category><![CDATA[crm2011]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[microsoft dynamics crm]]></category>
		<category><![CDATA[Microsoft Dynamics CRM 2011]]></category>
		<category><![CDATA[rest]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[sdk]]></category>
		<category><![CDATA[Web Resource]]></category>

		<guid isPermaLink="false">http://mscrmblogger.com/?p=986</guid>
		<description><![CDATA[If you need to be able to view the images attached to a CRM entity, this web resource (and solution) will help.  A managed and unmanaged solution that uses the base64 encoded pictures for immediate rendering.]]></description>
			<content:encoded><![CDATA[<p>Ok, a lot of people have been asking on the forums about how to display images that are attached to your CRM entity.  To help with that, here is a web-resource that will display images and fit them to the area allotted.  If you have more than 1 picture it will show some previous and next buttons below the photo.  The general idea here is to not only display an image on the form, but work across multiple browsers (and systems).  Leveraging JQuery and the REST SDK, this attachment image web-resource is a quick-and-easy image control, granted it doesn&#8217;t include all of the features the Silverlight CRMAttachmentImage control does.</p>
<p>Below you can see an example of what it looks like.  YOu can download the <a href='http://mscrmblogger.com/wp-content/uploads/2012/03/ImageBrowser_1_0_managed.zip'>managed solution here</a> and the <a href='http://mscrmblogger.com/wp-content/uploads/2012/03/ImageBrowser_1_0.zip'>unmanaged solution here</a>.</p>
<p><img src="http://mscrmblogger.com/wp-content/uploads/2012/03/040112_0359_CRM2011Atta1.png" alt=""/>
	</p>
<p><img src="http://mscrmblogger.com/wp-content/uploads/2012/03/040112_0359_CRM2011Atta2.png" alt=""/></p>
<p>You can specify the height and width in the parameters.</p>
<p><code>height:200|width:100</code></p>
<p>The image will resize to scale.</p>
<pre name="code" class="html">
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
  &lt;title&gt;Image Browser&lt;/title&gt;
  &lt;script type=&quot;text/javascript&quot; src=&quot;jq_1.7.2.min.js&quot;&gt;
&lt;/script&gt;
  &lt;script type=&quot;text/javascript&quot;&gt;
//&lt;![CDATA[
    $.fn.sandbox = function(fn) {
        var element = $(this).clone(), result;
        // make the element take space in the page but invisible
        element.css({visibility: 'hidden', display: 'block'}).insertAfter(this);
        // to override any display: none !important you may have been using
        element.attr('style', element.attr('style').replace('block', 'block !important'));
        result = fn.apply(element);
        element.remove();
        return result;
    };

    var GetDataParams = function()
    { //modified version of: http://technet.microsoft.com/en-us/library/gg327945.aspx
      //Get the any query string parameters and load them
      //into the vals array

      var vals = new Array();
      if (location.search != &quot;&quot;)
      {
        vals = location.search.substr(1).split(&quot;&amp;&quot;);
        for (var i in vals)
        {
          vals[i] = vals[i].replace(/\+/g, &quot; &quot;).split(&quot;=&quot;);
        }

        //look for the parameter named 'data'
        var found = false;
        for (var i in vals)
        {
          if (vals[i][0].toLowerCase() == &quot;data&quot;)
          {
            found = true;
            var datavals = decodeURIComponent(vals[i][1]).split(&quot;|&quot;);
            for (var i in datavals)
            {
              datavals[i] = datavals[i].replace(/\+/g, &quot; &quot;).split(&quot;=&quot;);
            }
            break;
          }
        }
        if (found) { return datavals; }
      }
      return null;
    }

    var ImageBrowser = function () {
      function getImage() {
        function getRecords(query, successCallback) {
            $.ajax({
                type: &quot;GET&quot;,
                async: true,
                contentType: &quot;application/json; charset=utf-8&quot;,
                url: query,
                datatype: &quot;json&quot;,
                beforeSend: function (request) {

                    request.setRequestHeader(&quot;Accept&quot;, &quot;application/json&quot;);
                },
                success: function(data, textStatus, xhr) {
                    if (data &amp;&amp; data.d &amp;&amp; data.d.results) {
                        successCallback(data.d.results)
                    }
                },
                error: function (xhr, textStatus, errorThrown) {
                    alert(&quot;Error : &quot; +
                        xhr.status + &quot;: &quot; +
                        xhr.statusText);
                }
            });
        }

        function buildQuery(s,c,f,t,p) {
            function getServerUrl() {  // From CrmRestKit.js
                var localServerUrl = window.location.protocol + &quot;//&quot; + window.location.host;
                var context = parent.Xrm.Page.context;

                if (context.isOutlookClient() &amp;&amp; !context.isOutlookOnline()) {
                    return localServerUrl;
                }
                else {
                    var crmServerUrl = context.getServerUrl();
                    crmServerUrl = crmServerUrl.replace(/^(http|https):\/\/([_a-zA-Z0-9\-\.]+)(:([0-9]{1,5}))?/, localServerUrl);
                    crmServerUrl = crmServerUrl.replace(/\/$/, &quot;&quot;);
                }
                return crmServerUrl;
            }
            return getServerUrl() + &quot;/XRMServices/2011/OrganizationData.svc/&quot; + s + &quot;/?&quot; +
                &quot;&amp;$filter=&quot; + f +
                &quot;&amp;$select=&quot; + c.join(',') +
                &quot;&amp;$top=&quot; + t +
                &quot;&amp;$skip=&quot; + p;
        }

        function updateImage(records) {
            var foundpicture = false;
            var picture;
            if (records.length&lt;1) {
                $(&quot;#picture&quot;).css(&quot;display&quot;,&quot;none&quot;);
                picture = $(&quot;#nopicture&quot;);
                picture.css(&quot;height&quot;,200);
                picture.css(&quot;width&quot;,120);
            } else {
                foundpicture = true;
                var source = &quot;data:&quot; + records[0].MimeType + &quot;;base64,&quot; + records[0].DocumentBody;
                picture = $(&quot;#picture&quot;);
                picture.css(&quot;height&quot;,&quot;auto&quot;);
                picture.css(&quot;width&quot;,&quot;auto&quot;);
            }

            picture.css(&quot;display&quot;,&quot;none&quot;);

            var pHeight = ImageBrowser.MaxHeight;
            var pWidth = ImageBrowser.MaxWidth;

            if (foundpicture) { picture.attr(&quot;src&quot;,source); }

            var pictureSize = picture.sandbox(function(){ return {height: this.height(), width: this.width()}; });

            var scale = 1;
            if (pictureSize.height&gt;pHeight) {
                if ((pictureSize.width-pWidth)&gt;(pictureSize.height-pHeight)) {
                    scale = pictureSize.width / pWidth;
                } else {
                    scale = pictureSize.height / pHeight;
                }
            }
            if (scale!=1) {
                var nh = pictureSize.height / scale;
                var nw = pictureSize.width / scale;

                picture.css(&quot;height&quot;,nh + &quot;px&quot;);
                picture.css(&quot;width&quot;,nw + &quot;px&quot;);
            }

            picture.css(&quot;display&quot;,&quot;block&quot;);
        }

        function updateFirstLast(records) {
            ImageBrowser.First = (ImageBrowser.Index==0) ? true : false;
            ImageBrowser.Last = (records.length&lt;1) ? true : false;

            $(&quot;#previous&quot;).css(&quot;display&quot;,ImageBrowser.First ? &quot;none&quot; : &quot;inline&quot;);
            $(&quot;#next&quot;).css(&quot;display&quot;,ImageBrowser.Last ? &quot;none&quot; : &quot;inline&quot;);
        }

        var setName = 'AnnotationSet';
        var columns = ['DocumentBody','MimeType'];

        var filter = &quot;ObjectId/Id eq (guid'&quot; + ImageBrowser.EntityId + &quot;') &quot; +
                     &quot;and startswith(MimeType,'image/') &quot; +
                     &quot;and ObjectTypeCode eq '&quot; + ImageBrowser.EntityName + &quot;'&quot;;

        var top = 1;
        var skip = ImageBrowser.Index;

        getRecords(buildQuery(setName,columns,filter,top,skip+1),updateFirstLast);
        getRecords(buildQuery(setName,columns,filter,top,skip),updateImage);
      }

      function previous() {
        if (ImageBrowser.Index&gt;0) {
            ImageBrowser.Index = ImageBrowser.Index - 1;
            getImage();
        }
      }

      function next() {
        if (ImageBrowser.Last==false) {
            ImageBrowser.Index = ImageBrowser.Index + 1;
            getImage();
        }
      }

      function init() {
        ImageBrowser.MaxWidth = $(&quot;body&quot;).width();
        ImageBrowser.MaxHeight = $(&quot;body&quot;).height();
        var data = GetDataParams();

        for (var i in data)
        {
            switch (data[i][0].toLowerCase())
            {
                case 'height':
                    var h = parseInt(data[i][1]);
                    var ph = $(&quot;body&quot;).height();
                    if (h&lt;ph) {
                        ImageBrowser.MaxHeight = h;
                    } else {
                        ImageBrowser.MaxHeight = ph;
                    }
                    break;

                case 'width':
                    var w = parseInt(data[i][1]);
                    var pw = $(&quot;body&quot;).width();
                    if (w&lt;pw) {
                        ImageBrowser.MaxWidth = w;
                    } else {
                        ImageBrowser.MaxWidth = pw;
                    }
                    break;

                $(&quot;#area&quot;).height(parseInt(data[i][1])); break;
            }
        }
        getImage();
      }

      return {
            EntityId: parent.Xrm.Page.data.entity.getId(),
            EntityName: parent.Xrm.Page.data.entity.getEntityName(),
            First: true,
            MaxHeight: 0,
            MaxWidth: 0,
            Last: false,
            Index: 0,
            Previous: previous,
            Next: next,
            Initialize: init
      };
    }();

  function next() { ImageBrowser.Next(); }
  function prev() { ImageBrowser.Previous(); }
  function onload() {ImageBrowser.Initialize(); }

  //]]&gt;
  &lt;/script&gt;
  &lt;style type=&quot;text/css&quot;&gt;
/*&lt;![CDATA[*/
  html, body, div {
    background-color: rgb(246, 248, 250);
    font-family: &quot;Tahoma&quot;, &quot;Helvetica&quot;, &quot;Arial&quot;,  &quot;Verdana&quot;, &quot;sans-serif&quot;;
    font-size:9px;
    padding: 0px;
    margin: 0px;
  }
  body {
    margin: 3px;
  }
  body, div.area {
    text-align: center;
  }
  img {
    border-style: none;
  }
  #nopicture {
    border: solid 1px black;
    font-size: 9px;
    text-align:center;
  }
  #nopicture p {
    padding-top: 30%;
  }
  /*]]&gt;*/
  &lt;/style&gt;
  &lt;meta charset=&quot;utf-8&quot; /&gt;
&lt;/head&gt;

&lt;body onload=&quot;onload();&quot; contenteditable=&quot;true&quot;&gt;
  &lt;div id=&quot;area&quot;&gt;
  &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;
  &lt;tr&gt;&lt;td id=&quot;picturearea&quot; colspan=&quot;2&quot;&gt;&lt;img id=&quot;picture&quot; class=&quot;picture&quot; src=&quot;&quot; /&gt;&lt;div id=&quot;nopicture&quot; style=&quot;display:none;&quot;&gt;&lt;p&gt;No Pictures&lt;/p&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
    &lt;td style=&quot;text-align:right;&quot;&gt;&lt;a id=&quot;previous&quot; href=&quot;javascript:prev();&quot; style=&quot;display:none&quot;&gt;&lt;img src=&quot;img_icons/previous.png&quot; /&gt;&lt;/a&gt;&lt;/td&gt;
    &lt;td style=&quot;text-align:left;&quot;&gt;&lt;a id=&quot;next&quot; href=&quot;javascript:next();&quot; style=&quot;display:none&quot;&gt;&lt;img src=&quot;img_icons/next.png&quot; /&gt;&lt;/a&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  &lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Thanks to <a href="http://wvega.com/246/get-height-of-a-hidden-element-using-jquery/" target="_blank">Willington&#8217;s Blog</a> for the sandbox jquery function.</p>
]]></content:encoded>
			<wfw:commentRss>http://mscrmblogger.com/2012/03/31/imagebrowser-webresource/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>InfoPath to CRM: Accepting Emailed InfoPath Forms</title>
		<link>http://mscrmblogger.com/2011/11/21/infopath-to-crm-accepting-emailed-infopath-forms/</link>
		<comments>http://mscrmblogger.com/2011/11/21/infopath-to-crm-accepting-emailed-infopath-forms/#comments</comments>
		<pubDate>Mon, 21 Nov 2011 19:05:51 +0000</pubDate>
		<dc:creator>Carlton Colter</dc:creator>
				<category><![CDATA[API-SDK]]></category>
		<category><![CDATA[Extensions]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Web Resources]]></category>
		<category><![CDATA[contact]]></category>
		<category><![CDATA[control]]></category>
		<category><![CDATA[crm]]></category>
		<category><![CDATA[crm 2011]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[InfoPath]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jscript]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[microsoft dynamics crm]]></category>
		<category><![CDATA[Microsoft Dynamics CRM 2011]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[Web Resource]]></category>

		<guid isPermaLink="false">http://mscrmblogger.com/?p=889</guid>
		<description><![CDATA[Everybody loves to use InfoPath forms.  And let's face it, we all wish we could just take them and put them into CRM.  This post delves into how I integrated InfoPath &#38; CRM to dynamically allow InfoPath forms received by email into CRM records.  It is still <i>under development</i>, but the source code has been partially tested and works.]]></description>
			<content:encoded><![CDATA[<p>Everybody loves to use InfoPath forms.  And let&#8217;s face it, we all wish we could just take them and put them into CRM.  What I&#8217;ve written is a simple way to do that without the hassle of figuring out how to bind the InfoPath form schema to a custom WCF service.  It still doesn&#8217;t do everything I want it to, but it works, so I figured I&#8217;d go ahead and put it out there for everyone to look at, play with, and even use.</p>
<p>If you are interested in this solution, you can download the following:</p>
<ul>
<li><a href='http://mscrmblogger.com/wp-content/uploads/2011/11/InfoPath_1_0_0_0_managed.zip'>Managed Solution</a> (this is the only thing you need)</li>
<li><a href='http://mscrmblogger.com/wp-content/uploads/2011/11/InfoPath_1_0_0_0.zip'>Unmanaged Solution</a> (in case you want to modify mine, like add grid support, it is on my to-do list)</li>
<li><a href='http://mscrmblogger.com/wp-content/uploads/2011/11/InfoPath4CRMSourceCode.zip'>Source Code</a> (this is in case you would prefer to use a WCF service or if you just want to play around with my code)</li>
</ul>
<p>Once you&#8217;ve installed the managed solution, you&#8217;ll need to do the following to create / setup an InfoPath form:</p>
<ol>
<li>
<p>For this particular InfoPath integration, you need to create InfoPath Forms that mirror a CRM Entity.<br />
<strong>Note: </strong><em>You can always create a new entity for the form data.</em></p>
<p style="text-align: center"><img src="http://mscrmblogger.com/wp-content/uploads/2011/11/112111_1905_InfoPathtoC13.png" alt=""/></p>
</li>
<li>
<p>Rename the default form Group to the name of the entity (ex: Contact)</p>
<p style="text-align: center"><img src="http://mscrmblogger.com/wp-content/uploads/2011/11/112111_1905_InfoPathtoC23.png" alt=""/></p>
</li>
<li>
<p>Inside CRM create the InfoPath form (it is an entity included in the solution), select the entity and save the form.
</p>
<p style="text-align: center"><img src="http://mscrmblogger.com/wp-content/uploads/2011/11/112111_1905_InfoPathtoC31.png" alt=""/></p>
</li>
<li>
<p>Once it has been saved, you can copy the ID using the &#8220;Copy ID&#8221; link in the header.<br />
<br /><strong>Note: </strong>If you do not select the <em>Allow Any CRM Field </em>checkbox, you will need to add the individual Fields, which can be found in the left navigation.</p>
</li>
<li>
<p>In the InfoPath Form Designer, add a field named SubmissionCode with the Default Value as the ID you just copied.<br />
<br /><b>Note:</b> Using the submission code allows us to check and see if the form is valid, active, and allowed.</p>
<p style="text-align: center"><img src="http://mscrmblogger.com/wp-content/uploads/2011/11/submissioncode.png" alt=""/></p>
</li>
<li>
<p>Add a field for each of the fields in CRM that you want to be available, selecting the appropriate data type.<br />
<br /><b>Note:</b> Unfortunately I have not had the time to test the fields and have been using the checkbox on the infopath form record to enable any/all CRM fields.  However, I did not want to delay releasing the code and information as it currently is.  If someone identifies a problem with this or any other section of the code, I&#8217;ll be happy to look into it and work on resolving the issue.</p>
<p style="text-align: center"><img src="http://mscrmblogger.com/wp-content/uploads/2011/11/112111_1905_InfoPathtoC53.png" alt=""/></p>
</li>
<li>
<p>Layout the fields on the form, then click File &gt; Submit Options &gt; To Email</p>
<p style="text-align: center"><img src="http://mscrmblogger.com/wp-content/uploads/2011/11/112111_1905_InfoPathtoC63.png" alt=""/></p>
</li>
<li>
<p>Enter the Queue email or where you want new forms to be submitted.</p>
<p style="text-align: center"><img src="http://mscrmblogger.com/wp-content/uploads/2011/11/112111_1905_InfoPathtoC73.png" alt=""/></p>
</li>
<li>
<p>Click Next.</p>
<p style="text-align: center"><img src="http://mscrmblogger.com/wp-content/uploads/2011/11/112111_1905_InfoPathtoC83.png" alt=""/></p>
</li>
<li>
<p>Click Finish.</p>
<p style="text-align: center"><img src="http://mscrmblogger.com/wp-content/uploads/2011/11/112111_1905_InfoPathtoC93.png" alt=""/></p>
</li>
<li>Save and close the form designer.</li>
<li>
<p>Open the form and test submission.</p>
<p style="text-align: center"><img src="http://mscrmblogger.com/wp-content/uploads/2011/11/112111_1905_InfoPathtoC103.png" alt=""/></p>
</li>
</ol>
<p>Once the email comes into CRM, the process of reading the form is easy; you just open it up and click the <img src="http://mscrmblogger.com/wp-content/uploads/2011/11/112111_1905_InfoPathtoC113.png" alt=""/> Import InfoPath button on the ribbon.</p>
<p>Usually I would post the source-code and comment on how it works in great detail, but this time, it really depends on which component.  There is a plugin and WCF service written in C# as well as two Jscript files, one for the buttons and one for the InfoPath form inside CRM that creates a drop-down of the entities in CRM.  I would suggest downloading the unmanaged solution and source-code if you want to delve into those items.</p>
<p>Now, for complex situations or form conversions, binding the InfoPath schema is the way to go.  Using that method (the one described in detail on <a href="http://blogs.msdn.com/b/philoj/archive/2005/11/08/490200.aspx">Philo&#8217;s Weblog</a>) you can import the InfoPath form schema into Visual Studio:</p>
<ol>
<li>Create an InfoPath form and lay it out the way you want it.
</li>
<li>Extract the form files (File | Extract Form Files) to a location you can find later.
</li>
<li>Close the InfoPath form designer.
</li>
<li>Open the Visual Studio command prompt.
</li>
<li>Change to the directory where you extracted the files<br /><strong>cd c:\myinfopathfiles<br />
</strong></li>
<li>Run xsd against the myschema.xsd in that directory, and specify the namespace you would like to use.<br /><strong>Note: </strong>My WCF namespace is CrmInfoPathService and my plugin namespace is InfoPathPlugin.<br /><strong>xsd.exe myschema.xsd /classes /l:cs /n:InfoPathPlugin<br />
</strong></li>
<li>Then you can deserialize the xml into the object and store it in CRM or any other system using the logic embedded in your code.</li>
</ol>
<p>The key point to my solution was not to do something that everyone does on occasion, but to make something so that I can leverage it in the future and not have to create a new integration every time I wanted to leverage a new form.  Now, on that note, here are the list of things that if you delve into, I&#8217;d like to know, a.k.a. my to-do list for this project:
</p>
<ul>
<li>Add a button onto the grid for activities</li>
<li>Create a way to handle child entities.</li>
<li>Modify the plugin/WCF code to link the created entities to the form email using connections.</li>
<li>Change the button on the form to monitor for the results (success/failure) and report back to the user.</li>
<li><i>Any great ideas my readers think should be added!</i></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://mscrmblogger.com/2011/11/21/infopath-to-crm-accepting-emailed-infopath-forms/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Changing OptionSet Values on Yes/No Form Field Change</title>
		<link>http://mscrmblogger.com/2011/11/01/crm2011optionsetvalues/</link>
		<comments>http://mscrmblogger.com/2011/11/01/crm2011optionsetvalues/#comments</comments>
		<pubDate>Tue, 01 Nov 2011 16:17:12 +0000</pubDate>
		<dc:creator>Carlton Colter</dc:creator>
				<category><![CDATA[Extensions]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Web Resources]]></category>
		<category><![CDATA[boolean]]></category>
		<category><![CDATA[crm]]></category>
		<category><![CDATA[crm 2011]]></category>
		<category><![CDATA[CRM Online]]></category>
		<category><![CDATA[crm2011]]></category>
		<category><![CDATA[field]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jscript]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[microsoft dynamics crm]]></category>
		<category><![CDATA[Microsoft Dynamics CRM 2011]]></category>
		<category><![CDATA[onchange]]></category>
		<category><![CDATA[picklist]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[Web Resource]]></category>

		<guid isPermaLink="false">http://mscrmblogger.com/?p=870</guid>
		<description><![CDATA[<p>Recently someone posted a question about the article I had written for CRM 4 as an example.  Here is the 2011 version to hopefully help people find the proper information.</p>]]></description>
			<content:encoded><![CDATA[<p>Recently I&#8217;ve received some questions on how to change the optionset (previously called picklist) values in CRM 2011 the same way I did in my <a href="http://mscrmblogger.com/2009/10/03/changing-picklist-values-on-yesno-form-field-change/">previous CRM 4 post</a> about using the OnChange event of a yes/no field to change the values of a picklist.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/gg334266.aspx">This technet page shows the methods available for the different types of controls.</a></p>
<p><strong>Here is an example of how to change the optionset based on a yes/no field:</strong></p>
<pre name="code" class="javascript">
function BuildOptionSet(picklist, valuelist)
{
	picklist.clearOptions();
	for(var i=0; i&lt;valuelist.length; i++)
	{
		var listitem = valuelist[i];
		picklist.addOption(listitem[0], listitem[1]);
	}
}

var lista = new Array();
lista[0] = new Array('Alpha',0);
lista[1] = new Array('Beta',1);

var listb = new Array();
listb[0] = new Array('Charlie',2);
listb[1] = new Array('Delta',3);

var uselista = Xrm.Page.data.entity.attributes.get("YesNo").getValue();
var optionset = Xrm.Page.ui.controls.get("OptionSet");

if (uselista==true) {
   BuildOptionSet(optionset, lista);
} else {
   BuildOptionSet(optionset, listb);
}
</pre>
<p>You just need to change the values of lista and listb and the YesNo and OptionSet lines to reflect the fields on your form, and add it to the onchange event of the dropdown Yes/No form field.</p>
]]></content:encoded>
			<wfw:commentRss>http://mscrmblogger.com/2011/11/01/crm2011optionsetvalues/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CRM 2011: Slider Form Control Web Resource</title>
		<link>http://mscrmblogger.com/2011/10/04/crmslider/</link>
		<comments>http://mscrmblogger.com/2011/10/04/crmslider/#comments</comments>
		<pubDate>Tue, 04 Oct 2011 20:23:11 +0000</pubDate>
		<dc:creator>Carlton Colter</dc:creator>
				<category><![CDATA[API-SDK]]></category>
		<category><![CDATA[Extensions]]></category>
		<category><![CDATA[General API Usage]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Web Resources]]></category>
		<category><![CDATA[control]]></category>
		<category><![CDATA[crm]]></category>
		<category><![CDATA[crm 2011]]></category>
		<category><![CDATA[CRM Online]]></category>
		<category><![CDATA[crm2011]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jscript]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[microsoft dynamics crm]]></category>
		<category><![CDATA[Microsoft Dynamics CRM 2011]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[slidebar]]></category>
		<category><![CDATA[slider]]></category>
		<category><![CDATA[Web Resource]]></category>

		<guid isPermaLink="false">http://mscrmblogger.com/?p=804</guid>
		<description><![CDATA[Here is another web-resource html control to expand your CRM forms.  It is a slider control for CRM with step control.  It provides a graphical way to slide a value up and down.]]></description>
			<content:encoded><![CDATA[<p>Here is another web-resource html control to expand your CRM forms.  It is a slider control for CRM with step control.</p>
<p>Below is an example of the slider control in action, and you can <a href='http://mscrmblogger.com/wp-content/uploads/2011/10/SliderFormControl_1_0_managed.zip'>click here to download a solution</a> to import the web-resources into your CRM deployment (it is a managed solution with no entities, just like the <a href="http://mscrmblogger.com/2011/09/20/crm-2011-star-rating-control/" target="_blank">star rating control</a>).  If you want the unmanaged solution you can download it <a href='http://mscrmblogger.com/wp-content/uploads/2011/10/SliderFormControl_1_0.zip'>here</a>.</p>
<p><a href="http://mscrmblogger.com/wp-content/uploads/2011/10/slider2.png"><img src="http://mscrmblogger.com/wp-content/uploads/2011/10/slider2.png" alt="" title="Slider Form Control" width="816" height="360" class="aligncenter size-full wp-image-806" /></a></p>
<p>Ok, once you have the web-resource loaded into your CRM deployment, you&#8217;ll need to create a new field to store the slider value and put it on the form, but uncheck the visible box.</p>
<p>Add the Web-Resource to the form, check the box to <strong>display the label on the form</strong>, and then enter your parameters.  I like using a pipe separator.  The available parameters are:</p>
<ul>
<li><strong>min</strong>: minimum value</li>
<li><strong>max</strong>: maximum value</li>
<li><strong>field</strong>: the CRM field to store the value in</li>
<li><strong>step</strong>: the step increase</li>
<li><strong>stepoverride</strong>: don&#8217;t use the step when a value is manually entered</li>
</ul>
<p><a href="http://mscrmblogger.com/wp-content/uploads/2011/10/Slider_Score_Resource1.png"><img src="http://mscrmblogger.com/wp-content/uploads/2011/10/Slider_Score_Resource1.png" alt="" title="Slider_Score_Resource1" width="486" height="615" class="aligncenter size-full wp-image-825" /></a></p>
<p>Make sure to click on the formatting tab and set the <strong>number of rows to 1</strong>, <strong>scrolling to Never</strong>, and uncheck the box to <strong>display the border</strong>.</p>
<p><a href="http://mscrmblogger.com/wp-content/uploads/2011/10/Slider_Score_Resource2.png"><img src="http://mscrmblogger.com/wp-content/uploads/2011/10/Slider_Score_Resource2.png" alt="" title="Slider_Score_Resource2" width="486" height="622" class="aligncenter size-full wp-image-826" /></a></p>
<p>Then move the hidden field down and out the way.  If you have a lot of fields you are accessing through form scripts you could just drop them into a hidden section.</p>
<p><a href="http://mscrmblogger.com/wp-content/uploads/2011/10/Score-Field.png"><img src="http://mscrmblogger.com/wp-content/uploads/2011/10/Score-Field.png" alt="" title="Score Field" width="544" height="251" class="aligncenter size-full wp-image-828" /></a></p>
<p>Here is the code for the slider control HTML web resource.</p>
<pre name="code" class="html">
&lt;html&gt;
&lt;head&gt;
  &lt;title&gt;Slider Control&lt;/title&gt;
  &lt;script type=&quot;text/javascript&quot;&gt;
var Settings = {};
Settings.Min = 0;
Settings.Max = 100;
Settings.Step = 5;
Settings.Value = 50;
Settings.Field = null;
Settings.AllowStepOverride = false;

var Slider = {};
Slider.Drag = false;

Slider.Initialize = function Slider(id,min,max,step,value,onchange) {
  Settings.Min = min;
  Settings.Max = max;
  Settings.Step = step;
  Slider.Value = value;

  var ihtml = &quot;&quot;;
  ihtml += &quot;&lt;table width='100%' cellspacing='0' cellpadding='0'&gt;&lt;tr&gt;&quot;;
  ihtml += &quot;&lt;td class='left-bracket'&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='value'&gt;&quot;;
  ihtml += &quot;&lt;input class='value' id='value' type='text' onchange='Slider.SetValue();' /&gt;&quot;;
  ihtml += &quot;&lt;/td&gt;&lt;td class='right-bracket'&gt;&amp;nbsp;&lt;/td&gt;&quot;;
  ihtml += &quot;&lt;td class='slider-left' /&gt;&lt;td class='slider-area' id='&quot;+id+&quot;-area' &gt;&quot;;
  ihtml += &quot;&lt;div id='&quot;+id+&quot;-selector' class='slider-selector' /&gt;&lt;/td&gt;&quot;
  ihtml += &quot;&lt;td class=&#39;slider-right&#39; /&gt;&lt;/tr&gt;&lt;/td&gt;&lt;/table&gt;&quot;;
  var p = document.getElementById(id);
  p.innerHTML = ihtml;

  Slider.Element = document.getElementById(id+&quot;-area&quot;);
  Slider.Element.attachEvent(&quot;onmousedown&quot;,Slider.OnMouseClick);

  Slider.Id = id;
  Slider.Selector = document.getElementById(id+&quot;-selector&quot;);
  Slider.Selector.attachEvent(&quot;onmousedown&quot;,Slider.OnMouseDown);
  Slider.Selector.attachEvent(&quot;onmousemove&quot;,Slider.OnMouseMove);
  Slider.Selector.attachEvent(&quot;onmouseup&quot;,Slider.OnMouseUp);
  Slider.Selector.attachEvent(&quot;onmouseleave&quot;,Slider.OnMouseUp);

  Slider.UpdatePosition();
}

Slider.SliderRatio = function() {
  var num =  Settings.Max - Settings.Min;
  var den = parseFloat(Slider.Element.offsetWidth)-parseFloat(Slider.Selector.offsetWidth);
  return den/num;
};

Slider.UpdatePosition = function () {
  Slider.Position = Math.round(Slider.Value*Slider.SliderRatio());
  Slider.SetPosition();
};

Slider.OnMouseClick = function(e) {
  Slider.Position = e.clientX - (8+Slider.Selector.offsetLeft-parseInt(Slider.Selector.style.left.replace(&quot;px&quot;,&quot;&quot;)));
  Slider.SetPosition();
  Slider.OnChange(Slider.Value);
}

Slider.SetPosition = function() {
  if (Slider.Position&lt;0) Slider.Position = 0;
  var max = Slider.Element.offsetWidth-Slider.Selector.offsetWidth;
  if (Slider.Position&gt;max) Slider.Position = max;

  Slider.Selector.style.left = Slider.Position + &quot;px&quot;;

  var i = Math.round(Slider.Position/Slider.SliderRatio()) + Settings.Min;
  i = (Math.floor(i/Settings.Step))*Settings.Step;

  Slider.Value = i;

  var val = document.getElementById('value');
  if (val===null) return;
  val.value = i;
}

Slider.SetValue = function() {
  var val = document.getElementById('value');
  if (Settings.AllowStepOverride) {
    Slider.Value = val.value;
  } else {
    Slider.Value = Math.round(val.value/Settings.Step)*Settings.Step;
  }
  if (Slider.Value&lt;Settings.Min) Slider.Value = Settings.Min;
  if (Slider.Value&gt;Settings.Max) Slider.Value = Settings.Max;
  Slider.UpdatePosition();
}

Slider.OnMouseDown = function(e)  {
  Slider.Drag = true;
}

Slider.OnMouseMove = function(e) {
  if (Slider.Drag) {
    Slider.Position = e.clientX - (8+Slider.Selector.offsetLeft-parseInt(Slider.Selector.style.left.replace(&quot;px&quot;,&quot;&quot;)));
    Slider.SetPosition();
  }
};

Slider.OnMouseUp = function(e) {
  if (Slider.Drag) {
    Slider.Drag = false;
    Slider.OnChange(Slider.Value);
  }
};

Slider.OnChange = function(val) {
  parent.Xrm.Page.data.entity.attributes.get(Settings.Field).setValue(val);
};

var InitializeSlider = function() {
  var data = WebResource.GetDataParams();
  var sliderBox = document.getElementById(&quot;sliderBox&quot;);

  for (var i in data)
  {
    switch (data[i][0].toLowerCase())
	{
	  case 'min': Settings.Min = parseInt(data[i][1],10); break;
	  case 'max': Settings.Max = parseInt(data[i][1],10); break;
	  case 'step': Settings.Step = parseInt(data[i][1],10); break;
	  case 'value': Settings.Value = parseInt(data[i][1],10); break;
	  case 'field': Settings.Field = data[i][1]; break;
	  case 'stepoverride': Settings.AllowStepOverride = (data[i][1]=='true'); break;
	  default:break;
	}
  }

  Slider.Initialize(&quot;slider&quot;,Settings.Min,Settings.Max,Settings.Step,Settings.Value,null)

  if (Settings.Field!=null) {
    var val = parent.Xrm.Page.data.entity.attributes.get(Settings.Field).getValue();
	if (val!==null) {
	  var num = parseInt(val);
	  Slider.Value = num;
	  Slider.UpdatePosition();
	}
  }
};

var WebResource = {};

WebResource.GetDataParams = function()
{ //modified version of: http://technet.microsoft.com/en-us/library/gg327945.aspx
  //Get the any query string parameters and load them
  //into the vals array

  var vals = new Array();
  if (location.search !== &quot;&quot;)
  {
    vals = location.search.substr(1).split(&quot;&amp;&quot;);
    for (var i in vals)
    {
      vals[i] = vals[i].replace(/\+/g, &quot; &quot;).split(&quot;=&quot;);
    }

    //look for the parameter named 'data'
    var found = false;
        var datavals;
    for (var j in vals)
    {
      if (vals[j][0].toLowerCase() == &quot;data&quot;)
      {
        found = true;
        datavals = decodeURIComponent(vals[j][1]).split(&quot;|&quot;);
        for (var k in datavals)
        {
          datavals[k] = datavals[k].replace(/\+/g, &quot; &quot;).split(&quot;=&quot;);
        }
        break;
      }
    }
    if (found) { return datavals; }
  }
  return null;
};
  &lt;/script&gt;
  &lt;style type=&quot;text/css&quot;&gt;
html, body {
  padding: 0px;
  margin: 0px;
  border: 0px;
  background-color: rgb(246, 248, 250);
  overflow:hidden;
}
.slider-left, .slider-area, .slider-right {
  background-image:url(img/bar.png);
  background-repeat:repeat-x;
  height:17px;
  padding:0px;
  margin:0px;
  cursor:hand;
}
.slider-left, .slider-right {
  width: 7px;
}
div.slider-selector {
  background-image:url(img/selector.png);
  background-repeat:no-repeat;
  width:15px;
  height:17px;
  position: relative;
  cursor:hand;
}
td.left-bracket, td.right-bracket {
  background-repeat:no-repeat;
  height:17px;
  width:6px;
  display:inline;
}
td.left-bracket {
  background-image:url(img/left_bracket.png);

}
td.right-bracket {
  background-image:url(img/right_bracket.png);
}
td.value {
  background-image:url(img/val_bk.png);
  background-repeat:repeat-x;
  height:17px;
  width:30px;
}
input.value {
  border: none;
  font:11px segoe ui,tahoma,arial;
  height:17px;
  width:30px;
  background-color:transparent;
  vertical-align:top;
  padding-top:1px;
  text-align:center;
}
  &lt;/style&gt;
&lt;/head&gt;
&lt;body onload=&quot;InitializeSlider();&quot;&gt;
&lt;div id=&quot;slider&quot;&gt;&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Thanks to <a href="http://manishmistry.wordpress.com" target="_blank">Manish Mistry</a> comment on my star control for refreshing the iframe when you change the value, you could do the same on this control.  However, you could also just set the value and update the position. The only reason I get the control&#8217;s object and it&#8217;s id is because I&#8217;m not 100% sure the id will always match, even though all my tests indicate it does.</p>
<pre name="code" class="javascript">
var control = Xrm.Page.ui.controls.get('WebResource_Score');
var id      = control.getObject().id;
var frame   = document.frames[id];
frame.Slider.Value = 50;
frame.Slider.UpdatePosition();
</pre>
<p>One of my TODO&#8217;s is to join my web resources HTML form controls into a single library once I have enough of them so that people can leverage them in an easier manner.  If anyone has any ideas for custom controls for Dynamics CRM, let me know and I&#8217;ll see if I can build it.</p>
]]></content:encoded>
			<wfw:commentRss>http://mscrmblogger.com/2011/10/04/crmslider/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>CRM 2011: Star Rating Form Control</title>
		<link>http://mscrmblogger.com/2011/09/20/crm-2011-star-rating-control/</link>
		<comments>http://mscrmblogger.com/2011/09/20/crm-2011-star-rating-control/#comments</comments>
		<pubDate>Wed, 21 Sep 2011 02:06:14 +0000</pubDate>
		<dc:creator>Carlton Colter</dc:creator>
				<category><![CDATA[API-SDK]]></category>
		<category><![CDATA[Extensions]]></category>
		<category><![CDATA[General API Usage]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Scoperta]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Web Resources]]></category>
		<category><![CDATA[control]]></category>
		<category><![CDATA[crm]]></category>
		<category><![CDATA[crm 2011]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jscript]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[microsoft dynamics crm]]></category>
		<category><![CDATA[Microsoft Dynamics CRM 2011]]></category>
		<category><![CDATA[rating]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[Web Resource]]></category>

		<guid isPermaLink="false">http://mscrmblogger.com/2011/09/20/crm-2011-star-rating-control/</guid>
		<description><![CDATA[<p>Another HTML control example that adds a star rating form control to CRM 2011 as a web-resource.  It includes a managed solution that you can download and install as well as the source and all images used in creating the solution.</p>]]></description>
			<content:encoded><![CDATA[<p>To expand on the technique used for my previous post on <a href="http://mscrmblogger.com/2011/05/11/crm-2011-making-the-state-field-a-drop-down/">making the state field a drop down</a> here is a star rating field control so that you can get a nice visual star rating control that is configurable.</p>
<p>Below is an example of the star rating control in action, and you can <a href='http://mscrmblogger.com/wp-content/uploads/2011/09/RatingControl_1_0_managed.zip'>click here to download a solution</a> to import the web-resources into your CRM deployment (it is a managed solution with no entities).</p>
<p><img src="http://mscrmblogger.com/wp-content/uploads/2011/09/092111_0206_CRM2011Star11.png" alt="" class="aligncenter size-full" /></p>
<p>Ok, once you have the web-resource loaded into your CRM deployment, you&#8217;ll need to create a new field to store the rating and put it on the form, but uncheck the visible box.</p>
<p><img src="http://mscrmblogger.com/wp-content/uploads/2011/09/092111_0206_CRM2011Star21.png" alt="" class="aligncenter size-full" /></p>
<p>Add the Web-Resource to the form, and check the box to <strong>display the label on the form</strong>.</p>
<p>Then enter your parameters (I like using a pipe as a separator).  The available parameters are:</p>
<ul>
<li><strong>min</strong>: minimum star rating – really should always be 1</li>
<li><strong>max</strong>: maximum star rating – maybe 5 or 10</li>
<li><strong>field</strong>: the CRM field to store the value in</li>
<li><strong>showvalue</strong>: whether or not to display the numerical value</li>
</ul>
<p><img src="http://mscrmblogger.com/wp-content/uploads/2011/09/092111_0206_CRM2011Star31.png" alt="" class="aligncenter size-full" /></p>
<p>Make sure to click on the formatting tab and set the <strong>number of rows to 1</strong>, <strong>scrolling to Never</strong>, and check the box to <strong>display the border</strong>.</p>
<p><img src="http://mscrmblogger.com/wp-content/uploads/2011/09/092111_0206_CRM2011Star41.png" alt="" class="aligncenter size-full" /></p>
<p>Then move the hidden field down and out the way.  If you have a lot of fields you are accessing through form scripts you could just drop them into a hidden section.</p>
<p><img src="http://mscrmblogger.com/wp-content/uploads/2011/09/092111_0206_CRM2011Star51.png" alt="" class="aligncenter size-full" /></p>
<p>Now that you know how to set it up, let&#8217;s go ahead and look at the code.</p>
<pre name="code" class="html">
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
  &lt;title&gt;Rating Control&lt;/title&gt;
  &lt;link href=&quot;/_common/styles/fonts.css.aspx?lcid=1033&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
  &lt;link href=&quot;/_common/styles/global.css.aspx?lcid=1033&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
  &lt;link href=&quot;/_common/styles/select.css.aspx?lcid=1033&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
  &lt;script type=&quot;text/javascript&quot;&gt;
var Rating = {};

// Default Values
Rating.ShowValue = false;
Rating.Max = 5;
Rating.Min = 1;
Rating.Field = '';
Rating.Value = null;

Rating.Highlight = function(index)
{
  var val = document.getElementById('rating_value');
  if (index===null) {
    index = -1;
    val.innerHTML = '[Not Set]';
  } else {
    val.innerHTML = '['+index+'/'+Rating.Max+']';
  }
  for(var i=Rating.Min; i&lt;=Rating.Max;i++)
  {
    if (i&lt;=index) {
      document.getElementById(&quot;rating_&quot;+i).className = &quot;staron&quot;;
    } else {
      document.getElementById(&quot;rating_&quot;+i).className = &quot;staroff&quot;;
    }
  }
};

Rating.HolderRollover = function() {
  if (Rating.Value !== null) {
    var r = document.getElementById('rating_remove');
    r.className = 'stardel';
  }
};

Rating.HolderRollout = function() {
  var r = document.getElementById('rating_remove');
  r.className = 'stardel2';
};

Rating.Rollover = function(index) {
  Rating.Highlight(index);
};

Rating.Rollout = function()
  {
  Rating.Highlight(Rating.Value);
};

Rating.Set = function(index) {
  Rating.Value = index;
  if (index&lt;0) {
    parent.Xrm.Page.data.entity.attributes.get(Rating.Field).setValue(null);
  } else {
    parent.Xrm.Page.data.entity.attributes.get(Rating.Field).setValue(Rating.Value);
  }
  Rating.Highlight(index);
};

Rating.Initialize = function() {
  var data = WebResource.GetDataParams();
  for (var i in data)
  {
    switch (data[i][0].toLowerCase())
        {
          case 'min': Rating.Min = parseInt(data[i][1],10); break;
          case 'max': Rating.Max = parseInt(data[i][1],10); break;
          case 'field': Rating.Field = data[i][1]; break;
          case 'showvalue': Rating.ShowValue = (data[i][1] == 'true'); break;
          default:break;
        }
  }
  var d = document.getElementById('starholder');
  for (var j=Rating.Min;j&lt;=Rating.Max;j++)
  {
    var el = &quot;&lt;span id='rating_&quot;+j+&quot;' &quot; +
             &quot;onmouseover='Rating.Rollover(&quot;+j+&quot;);' &quot; +
             &quot;onmouseout='Rating.Rollout();' &quot; +
             &quot;onclick='Rating.Set(&quot;+j+&quot;);' /&gt;&quot;;
    d.innerHTML += el;
  }

  var rel = &quot;&lt;span id='rating_remove' class='stardel2' &quot; +
            &quot;onclick='Rating.Set(null);' onmouseover='Rating.Rollover(null);' /&gt;&quot;;
  d.innerHTML += rel;

  var val = &quot;&lt;span id='rating_value' class='value' &quot; +
            (Rating.ShowValue ? &quot;&quot; : &quot;style='display:none' &quot;) +
            &quot;/&gt;&quot;;
  d.innerHTML += val; 

  Rating.Value = parent.Xrm.Page.data.entity.attributes.get(Rating.Field).getValue();
  Rating.Highlight(Rating.Value);
};

var WebResource = {};

WebResource.GetDataParams = function()
{ //modified version of: http://technet.microsoft.com/en-us/library/gg327945.aspx
  //Get the any query string parameters and load them
  //into the vals array

  var vals = new Array();
  if (location.search !== &quot;&quot;)
  {
    vals = location.search.substr(1).split(&quot;&amp;&quot;);
    for (var i in vals)
    {
      vals[i] = vals[i].replace(/\+/g, &quot; &quot;).split(&quot;=&quot;);
    }

    //look for the parameter named 'data'
    var found = false;
        var datavals;
    for (var j in vals)
    {
      if (vals[j][0].toLowerCase() == &quot;data&quot;)
      {
        found = true;
        datavals = decodeURIComponent(vals[j][1]).split(&quot;|&quot;);
        for (var k in datavals)
        {
          datavals[k] = datavals[k].replace(/\+/g, &quot; &quot;).split(&quot;=&quot;);
        }
        break;
      }
    }
    if (found) { return datavals; }
  }
  return null;
};
  &lt;/script&gt;
  &lt;style type=&quot;text/css&quot;&gt;
.staroff,.staron,.stardel,.stardel2 {
	height:15px;
	margin:1px 1px 1px 2px;
	width:15px
}

staroff,.staron,.stardel {
	background:no-repeat
}

.starholder {
	background:#FFF;
	padding:1px
}

.stardel {
	background:url(remove.png)
}

.staron {
	background:url(staron.png)
}

.staron,.staroff {
	margin-right:5px
}

.staroff {
	background:url(staroff.png)
}

.value {
	font:11px segoe ui,tahoma,arial;
	color:#000;
	height:17px;
	vertical-align:middle
}
  &lt;/style&gt;
&lt;/head&gt;

&lt;body onload=&quot;Rating.Initialize();&quot;&gt;
  &lt;table cellspacing=&quot;0&quot;
         cellpadding=&quot;0&quot;
         width=&quot;100%&quot;
         summary=&quot;star table&quot;&gt;
    &lt;tr&gt;
      &lt;td id=&quot;cell_dd&quot;&gt;
        &lt;div id=&quot;starholder&quot;
             style=&quot;width:100%;&quot;
             onmouseover=&quot;Rating.HolderRollover();&quot;
             onmouseout=&quot;Rating.HolderRollout();&quot;&gt;&lt;/div&gt;
      &lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<table>
<tr>
<td>These are the image files used:</td>
<td>
<a href="http://mscrmblogger.com/wp-content/uploads/2011/09/msblog_ratingstaron.png"><img src="http://mscrmblogger.com/wp-content/uploads/2011/09/msblog_ratingstaron.png" alt="" title="msblog_ratingstaron" width="15" height="15" class="aligncenter size-full wp-image-785" /></a></td>
<td>
<a href="http://mscrmblogger.com/wp-content/uploads/2011/09/msblog_ratingstaroff.png"><img src="http://mscrmblogger.com/wp-content/uploads/2011/09/msblog_ratingstaroff.png" alt="" title="msblog_ratingstaroff" width="15" height="15" class="aligncenter size-full wp-image-784" /></a></td>
<td>
<a href="http://mscrmblogger.com/wp-content/uploads/2011/09/msblog_ratingremove.png"><img src="http://mscrmblogger.com/wp-content/uploads/2011/09/msblog_ratingremove.png" alt="" title="msblog_ratingremove" width="15" height="15" class="aligncenter size-full wp-image-783" /></a></td>
<td>(<i>they are hidden in the managed solution</i>)</td>
</tr>
</table>
]]></content:encoded>
			<wfw:commentRss>http://mscrmblogger.com/2011/09/20/crm-2011-star-rating-control/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Use Microsoft Translator to translate text in CRM (Button on Ribbon)</title>
		<link>http://mscrmblogger.com/2011/09/14/use-microsoft-translator-to-translate-text-in-crm-button-on-ribbon/</link>
		<comments>http://mscrmblogger.com/2011/09/14/use-microsoft-translator-to-translate-text-in-crm-button-on-ribbon/#comments</comments>
		<pubDate>Wed, 14 Sep 2011 15:58:19 +0000</pubDate>
		<dc:creator>Carlton Colter</dc:creator>
				<category><![CDATA[Addons]]></category>
		<category><![CDATA[API-SDK]]></category>
		<category><![CDATA[Extensions]]></category>
		<category><![CDATA[General API Usage]]></category>
		<category><![CDATA[Integration]]></category>
		<category><![CDATA[Web Resources]]></category>
		<category><![CDATA[bing translator]]></category>
		<category><![CDATA[cases]]></category>
		<category><![CDATA[crm]]></category>
		<category><![CDATA[crm 2011]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jscript]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[microsoft dynamics crm]]></category>
		<category><![CDATA[Microsoft Dynamics CRM 2011]]></category>
		<category><![CDATA[microsoft translator]]></category>
		<category><![CDATA[ribbon]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[translate]]></category>
		<category><![CDATA[Web Resource]]></category>

		<guid isPermaLink="false">http://mscrmblogger.com/?p=695</guid>
		<description><![CDATA[Ever want to translate text from within CRM?  This solution adds a button on the ribbon to translate text from other languages to english using the Microsoft Bing Translator.]]></description>
			<content:encoded><![CDATA[<p>Do you have issues receiving request or information in various languages and need it translated to English (or another language)?  I found the need to translate something from any language to english just so when someone submits a case or puts some notes in another language it can quickly be translated.</p>
<p>Here is what my bing translator integration looks like.</p>
<p><a href="http://mscrmblogger.com/wp-content/uploads/2011/09/translator-screenshot.png"><img src="http://mscrmblogger.com/wp-content/uploads/2011/09/translator-screenshot.png" alt="" title="Implemented Translator Screenshot" width="730" height="671" class="aligncenter size-full wp-image-706" /></a></p>
<p>You can download an unmanaged solution to implement the bing translator for cases, letters, tasks, and emails, you can download it here: <a href='http://mscrmblogger.com/wp-content/uploads/2011/09/Translate_1_0.zip'>Translate_1_0.zip</a>.  It will not modify your forms, but if you have unmanaged ribbon buttons on those entities, it will remove them.  So to avoid that problem you can install <a href='http://mscrmblogger.com/wp-content/uploads/2011/09/Translate_1_0-ImageJS.zip'>the unmanaged solution with the JScript (that you need to edit to set your bing api key) and the images</a>, and then follow the RibbonDiff guide in the SDK to add the buttons, or install <a href='http://mscrmblogger.com/wp-content/uploads/2011/09/Translate_1_0-Ribbon-Managed.zip'>the managed solution</a> to add the button to the ribbons for cases, letters, tasks, and emails.</p>
<p>To start, I created a JScript file to include as a web-resource that I could leverage when a button is clicked on the ribbon.  This JScript file utilizes the Bing Translation WebServices to translate text.</p>
<p><i><b>YOU WILL NEED TO EDIT THE JSCRIPT FILE AND CHANGE &#8216;YOUR API KEY GOES HERE&#8217; TO CONTAIN YOUR API KEY.</b></i></p>
<pre name="code" class="javascript">
var bing = {};
bing.popup = {};
bing.language = {};

bing.appId = 'YOUR API KEY GOES HERE';
bing.language.text = '';
bing.language.from = '';
bing.language.to = 'en';

bing.language.detect = function (text,oncomplete)
{
  var src = &quot;https://api.microsofttranslator.com/V2/Ajax.svc/Detect?oncomplete=&quot; +
      oncomplete + &quot;&amp;appId=&quot;+ bing.appId + &quot;&amp;text=&quot; + text;
  var s = document.createElement(&quot;script&quot;);
  s.src = src;
  s.id = &quot;bingdetect&quot;;
  document.getElementsByTagName(&quot;head&quot;)[0].appendChild(s);
}

bing.language.translate = function(from,to,text,oncomplete)
{
  var src = &quot;https://api.microsofttranslator.com/V2/Ajax.svc/Translate?oncomplete=&quot; +
      oncomplete + &quot;&amp;appId=&quot; + bing.appId + &quot;&amp;from=&quot; + from +
      &quot;&amp;to=&quot; + to + &quot;&amp;text=&quot; + text;

  var s = document.createElement(&quot;script&quot;);
  s.src = src;
  s.id = &quot;bingtranslate&quot;;
  document.getElementsByTagName(&quot;head&quot;)[0].appendChild(s);
}

bing.popup.show = function(text)
{
  var idiv = document.createElement('div');
  idiv.id = &quot;bingtext&quot;;
  idiv.style.height = &quot;265px&quot;;
  idiv.style.width = &quot;306px&quot;;
  idiv.style.align = &quot;left&quot;;
  idiv.style.textAlign = &quot;left&quot;;
  idiv.style.backgroundColor = &quot;white&quot;;
  idiv.style.overflow = &quot;auto&quot;;
  idiv.style.padding = &quot;2px&quot;;
  idiv.style.margin = &quot;2px&quot;;
  idiv.style.border = &quot;1px solid black&quot;;
  idiv.innerHTML =  &quot;&lt;p&gt;&quot;+text+&quot;&lt;/p&gt;&quot;;

  var iurl = Xrm.Page.context.getServerUrl();
  iurl += &quot;WebResources/tran_img/translatelogo.gif&quot;;

  var img = document.createElement('img');
  img.src = iurl;

  var div = document.createElement('div');
  div.id = &quot;bingpopup&quot;;
  div.appendChild(img);
  div.appendChild(idiv);
  div.innerHTML += &quot;&lt;button style='text-align:center;width:60px;' onclick='bing.popup.copy();'&gt;Copy&lt;/button&gt;&amp;nbsp;&amp;nbsp;&quot;;
  div.innerHTML += &quot;&lt;button style='text-align:center;width:60px;' onclick='bing.popup.hide();'&gt;Close&lt;/button&gt;&quot;;
  div.style.position = &quot;absolute&quot;;
  div.style.backgroundColor = &quot;#20415F&quot;;
  div.style.border=&quot;1px solid black&quot;;
  div.style.left = &quot;50%&quot;;
  div.style.top = &quot;50%&quot;;
  div.style.color = &quot;black&quot;;
  div.style.padding = &quot;5px&quot;;
  div.style.width = &quot;320px&quot;;
  div.style.height = &quot;340px&quot;;
  div.style.marginLeft = &quot;-160px&quot;;
  div.style.marginTop = &quot;-170px&quot;;
  div.setAttribute(&quot;align&quot;,&quot;center&quot;);
  document.getElementsByTagName(&quot;body&quot;)[0].appendChild(div);
}

bing.popup.hide = function()
{
  var deleteElement = function(id) {
    var el = document.getElementById(id);
    el.parentNode.removeChild(el);
  }

  deleteElement(&quot;bingpopup&quot;);
  deleteElement(&quot;bingdetect&quot;);
  deleteElement(&quot;bingtranslate&quot;);
}

bing.popup.copy = function()
{
  var el = document.getElementById('bingtext');

  if (window.clipboardData &amp;&amp; window.clipboardData.setData)
  {
    window.clipboardData.setData(&quot;Text&quot;, el.innerText);
  }
}

bing.getSelectedText = function (p)
{
  if (p.getSelection)
  {
    text = p.getSelection();
  }
  else if (p.selection)
  {
    text = p.selection.createRange().text;
  }
  return text;
}

// get current control
bing.language.toolbarClick = function (ctrl)
{
  var text = '';
  if (window.getSelection)
  {
    text = window.getSelection();
  }
  else {
    text = bing.getSelectedText(document);
  }

  if (text==null || text=='') {
    if (ctrl==null) {
      ctrl = Xrm.Page.ui.getCurrentControl();
    }

    var entityName = Xrm.Page.data.entity.getEntityName();
    if (ctrl==null &amp;&amp; entityName.match(/letter|email|task/)) {
      ctrl = Xrm.Page.ui.controls.get('description');
    }

    if (ctrl==null) {
      alert('Please highlight the text to translate.');
      return;
    }

    if (ctrl.getControlType()!=&quot;standard&quot;) {
      return; // only standard
    }

    if (ctrl.getName()==&quot;notescontrol&quot;) {
      text = bing.getSelectedText(document.frames['notescontrol'].document);
      if (text==null || text == &quot;&quot;) {
        alert('Please highlight the text to translate.');
      }
    }

    if (text == null || text == &quot;&quot;) {
      var attr = ctrl.getAttribute();
      if (attr!=null) {
        var t = attr.getAttributeType();
        if (t.match(/string|memo/))
        {
          text = attr.getValue();
        }
      }
    }
  }

  if (text == null || text == &quot;&quot;) {
    // Nothing to translate
    return;
  }  

  text = encodeURIComponent(text);
  bing.language.text = text;

  bing.language.from = '';
  bing.language.detect(text,&quot;translate&quot;);
}

window.translate = function (response)
{
  bing.language.from = response;
  bing.language.translate(bing.language.from,bing.language.to,bing.language.text,&quot;translated&quot;);
}

window.translated = function (response)
{
  bing.popup.show(response);
}
</pre>
<p>The JScript uses the Bing Translate logo image (WebResources/tran_img/translatelogo.gif &#8211; you may need to change the path in the JScript):</p>
<p><a href="http://mscrmblogger.com/wp-content/uploads/2011/09/bingtranslatelogo.gif"><img src="http://mscrmblogger.com/wp-content/uploads/2011/09/bingtranslatelogo.gif" alt="" title="Bing Translator Logo" width="145" height="39" class="aligncenter size-full wp-image-700" /></a></p>
<p>I added some images for Microsoft Translate button images:</p>
<p><center></p>
<table style="background-color:white;padding:20px;color:black">
<tr>
<td style="border:1px solid black;height:65px;padding:7px;">
<a href="http://mscrmblogger.com/wp-content/uploads/2011/09/tran_icontranslate_16x16.png"><img src="http://mscrmblogger.com/wp-content/uploads/2011/09/tran_icontranslate_16x16.png" alt="" title="tran_icontranslate_16x16" width="16" height="16" /></a><br />16&#215;16 image<br />tran_icontranslate_16x16.png
</td>
<td style="width:20px" />
<td style="border:1px solid black;height:65px;padding:7px;">
<a href="http://mscrmblogger.com/wp-content/uploads/2011/09/tran_icontranslate_32x32.png"><img src="http://mscrmblogger.com/wp-content/uploads/2011/09/tran_icontranslate_32x32.png" alt="" title="tran_icontranslate_32x32" width="32" height="32" /></a><br />32&#215;32 image<br />tran_icontranslate_32x32.png
</td>
</tr>
</table>
<p>
</center></p>
<p>Then I added the buttons to the ribbons on the entities I wanted to have bing translation capabilities by following the <a href="http://msdn.microsoft.com/en-us/library/gg334341.aspx">SDK guidelines to add a button</a>.  Here is the RibbonDiffXml for a case.  You can follow the guide to change it to be on different entities.</p>
<pre name="code" class="xml">
&lt;RibbonDiffXml&gt;
  &lt;CustomActions&gt;
    &lt;CustomAction Id=&quot;bing.incident.form.Bing.CustomAction&quot;
                  Location=&quot;Mscrm.Form.incident.MainTab.Groups._children&quot;
                  Sequence=&quot;110&quot;&gt;
    &lt;CommandUIDefinition&gt;
      &lt;Group Id=&quot;bing.incident.form.Bing.Group&quot;
             Command=&quot;bing.incident.form.Bing.Command&quot;
             Title=&quot;$LocLabels:bing.incident.Bing.Title&quot;
             Sequence=&quot;39&quot;
             Template=&quot;Mscrm.Templates.Flexible2&quot;
             Image32by32Popup=&quot;$webresource:tran_icon/translate_32x32.png&quot;&gt;
      &lt;Controls Id=&quot;bing.incident.form.Bing.Controls&quot;&gt;
        &lt;Button Id=&quot;bing.incident.form.Bing.Button.BingTranslator&quot;
                Command=&quot;bing.incident.Bing.Button.BingTranslator.Command&quot;
                Sequence=&quot;10&quot;
                LabelText=&quot;$LocLabels:bing.incident.Bing.Button.BingTranslator.LabelText&quot;
                ToolTipTitle=&quot;$LocLabels:bing.incident.Bing.Button.BingTranslator.LabelText&quot;
                ToolTipDescription=&quot;$LocLabels:bing.incident.Bing.Button.BingTranslator.Description&quot;
                TemplateAlias=&quot;isv&quot;
                Image16by16=&quot;$webresource:tran_icon/translate_16x16.png&quot;
                Image32by32=&quot;$webresource:tran_icon/translate_32x32.png&quot; /&gt;
      &lt;/Controls&gt;
      &lt;/Group&gt;
    &lt;/CommandUIDefinition&gt;
    &lt;/CustomAction&gt;
    &lt;CustomAction Id=&quot;bing.incident.form.Bing.Popup.CustomAction&quot;
                  Location=&quot;Mscrm.Form.incident.MainTab.Scaling._children&quot;
                  Sequence=&quot;140&quot;&gt;
    &lt;CommandUIDefinition&gt;
      &lt;Scale Id=&quot;bing.incident.form.Bing.Popup.1&quot;
             GroupId=&quot;bing.incident.form.Bing.Group&quot;
             Sequence=&quot;85&quot;
             Size=&quot;Popup&quot; /&gt;
    &lt;/CommandUIDefinition&gt;
    &lt;/CustomAction&gt;
    &lt;CustomAction Id=&quot;bing.incident.form.Bing.MaxSize.CustomAction&quot;
                  Location=&quot;Mscrm.Form.incident.MainTab.Scaling._children&quot;
                  Sequence=&quot;120&quot;&gt;
    &lt;CommandUIDefinition&gt;
      &lt;MaxSize Id=&quot;bing.incident.form.Bing.MaxSize&quot;
               GroupId=&quot;bing.incident.form.Bing.Group&quot;
               Sequence=&quot;21&quot;
               Size=&quot;LargeLarge&quot; /&gt;
    &lt;/CommandUIDefinition&gt;
    &lt;/CustomAction&gt;
  &lt;/CustomActions&gt;
  &lt;Templates&gt;
    &lt;RibbonTemplates Id=&quot;Mscrm.Templates&quot;&gt;&lt;/RibbonTemplates&gt;
  &lt;/Templates&gt;
  &lt;CommandDefinitions&gt;
    &lt;CommandDefinition Id=&quot;bing.incident.Bing.Button.BingTranslator.Command&quot;&gt;
    &lt;EnableRules /&gt;
    &lt;DisplayRules /&gt;
    &lt;Actions&gt;
      &lt;JavaScriptFunction Library=&quot;$webresource:tran_js/bing.translate.js&quot;
                          FunctionName=&quot;bing.language.toolbarClick&quot;&gt;
      &lt;CrmParameter Value=&quot;SelectedControl&quot; /&gt;
      &lt;/JavaScriptFunction&gt;
    &lt;/Actions&gt;
    &lt;/CommandDefinition&gt;
    &lt;CommandDefinition Id=&quot;bing.incident.form.Bing.Command&quot;&gt;
    &lt;EnableRules&gt;&lt;/EnableRules&gt;
    &lt;DisplayRules /&gt;
    &lt;Actions /&gt;
    &lt;/CommandDefinition&gt;
  &lt;/CommandDefinitions&gt;
  &lt;RuleDefinitions&gt;
    &lt;TabDisplayRules /&gt;
    &lt;DisplayRules /&gt;
    &lt;EnableRules /&gt;
  &lt;/RuleDefinitions&gt;
  &lt;LocLabels&gt;
    &lt;LocLabel Id=&quot;bing.incident.Bing.Title&quot;&gt;
    &lt;Titles&gt;
      &lt;Title languagecode=&quot;1033&quot;
             description=&quot;Bing&quot; /&gt;
    &lt;/Titles&gt;
    &lt;/LocLabel&gt;
    &lt;LocLabel Id=&quot;bing.incident.Bing.Button.BingTranslator.LabelText&quot;&gt;
    &lt;Titles&gt;
      &lt;Title languagecode=&quot;1033&quot;
             description=&quot;Translate&quot; /&gt;
    &lt;/Titles&gt;
    &lt;/LocLabel&gt;
    &lt;LocLabel Id=&quot;bing.incident.Bing.Button.BingTranslator.Description&quot;&gt;
    &lt;Titles&gt;
      &lt;Title languagecode=&quot;1033&quot;
             description=&quot;Translate text area with bing!&quot; /&gt;
    &lt;/Titles&gt;
    &lt;/LocLabel&gt;
  &lt;/LocLabels&gt;
&lt;/RibbonDiffXml&gt;
</pre>
<p>Here are the files to download if you want to use it:</p>
<ul>
<li>Option A
<ul>
<li>Complete unmanaged solution: <a href='http://mscrmblogger.com/wp-content/uploads/2011/09/Translate_1_0.zip'>Translate_1_0.zip</a></li>
</ul>
</li>
<li>Option B
<ul>
<li>Unmanaged Image and JScript solution: <a href='http://mscrmblogger.com/wp-content/uploads/2011/09/Translate_1_0-ImageJS.zip'>Translate_1_0-ImageJS.zip</a>
<ul>
<li>You will need to edit the JScript to set your Bing API key.</li>
</ul>
</li>
<li>Managed Solution for the Ribbons on cases, letters, tasks, and emails: <a href='http://mscrmblogger.com/wp-content/uploads/2011/09/Translate_1_0-Ribbon-Managed.zip'>Translate_1_0-Ribbon-Managed.zip</a></li>
</ul>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://mscrmblogger.com/2011/09/14/use-microsoft-translator-to-translate-text-in-crm-button-on-ribbon/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Quickly Create Users in Active Directory from CSV for Demo Environment</title>
		<link>http://mscrmblogger.com/2011/05/05/create-users-in-ad/</link>
		<comments>http://mscrmblogger.com/2011/05/05/create-users-in-ad/#comments</comments>
		<pubDate>Thu, 05 May 2011 17:10:58 +0000</pubDate>
		<dc:creator>Carlton Colter</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[active directory]]></category>
		<category><![CDATA[create]]></category>
		<category><![CDATA[demo]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[users]]></category>

		<guid isPermaLink="false">http://mscrmblogger.com/?p=431</guid>
		<description><![CDATA[Recently I needed to create some AD users for my CRM demo environment, and since I hate doing tedious repetative tasks I ended up using a powershell script.  I thought I would share the script so that other people doing demos don't create users 1 by 1.]]></description>
			<content:encoded><![CDATA[<p>Recently I was creating a new demo environment and had to create some AD users to use in my CRM deployment.  I hate doing tedious repetative tasks one-by-one, and ended up using a modified version of the powershell script from: <a href="http://www.thejoyofcode.com/Creating_AD_user_accounts_in_PowerShell.aspx">http://www.thejoyofcode.com/Creating_AD_user_accounts_in_PowerShell.aspx</a> &#8211; so I figured I&#8217;d share it with everyone else so that when they need to mass create some users and just have their first and last name, this will help.</p>
<p><b>Here is the powerhsell code:</b></p>
<pre name="code" class="powershell">
$domain = (get-addomain).distinguishedname
$path = "OU=Employees,$domain"
$employees = Get-ADObject -Filter {distinguishedname -eq $path}
If ( -not $employees) {
  $employees = $domain.Create("OrganizationalUnit", "ou=Employees")
  $employees.SetInfo()
}

$users = import-csv "C:\Scripts\usersToBeCreated.csv"
$ldappath = "LDAP://$path"
$container = [ADSI] $ldappath
$users | foreach {
    $first = $_.FirstName
    $last = $_.LastName
    $username = "$first" + "." + "$last"
    $email = "$username" + "@demo.local"
    $newUser = $container.Create("User", "cn=" + $username)
    $newUser.Put("sAMAccountName", $username)
    $newUser.Put("givenname",$first)
    $newUser.Put("sn",$last)
    $newUser.Put("mail",$email)
    $newUser.Put("description","Demo Account")
    $newUser.SetInfo()
    $newUser.psbase.InvokeSet('AccountDisabled', $false)
    $newUser.SetInfo()
    $newUser.SetPassword("somethingG00D!")
}
</pre>
<p>Hopefully that will help someone else save some time.</p>
]]></content:encoded>
			<wfw:commentRss>http://mscrmblogger.com/2011/05/05/create-users-in-ad/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>CRM 2011: Required Fields</title>
		<link>http://mscrmblogger.com/2011/04/10/crm-2011-required-fields/</link>
		<comments>http://mscrmblogger.com/2011/04/10/crm-2011-required-fields/#comments</comments>
		<pubDate>Sun, 10 Apr 2011 22:00:53 +0000</pubDate>
		<dc:creator>Carlton Colter</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[crm]]></category>
		<category><![CDATA[crm 2011]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jscript]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Microsoft Dynamics CRM 2011]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://mscrmblogger.com/?p=410</guid>
		<description><![CDATA[This afternoon I was at the Microsoft Dynamics CRM booth at Convergence when someone asked me about required fields in CRM 2011. They wanted to know how to make fields required, but have different forms with different required fields for the same entity. First, in CRM 2011, when you make a field required by editing <a href='http://mscrmblogger.com/2011/04/10/crm-2011-required-fields/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>This afternoon I was at the Microsoft Dynamics CRM booth at Convergence when someone asked me about required fields in CRM 2011.  They wanted to know how to make fields required, but have different forms with different required fields for the same entity.</p>
<p>First, in CRM 2011, when you make a field required by editing the field, you are making it required for all forms (that the field is on).</p>
<p><a href="http://mscrmblogger.com/wp-content/uploads/2011/04/RequirementLevel.png"><img src="http://mscrmblogger.com/wp-content/uploads/2011/04/RequirementLevel.png" alt="" title="Requirement Level when editing a field" width="653" height="267" class="aligncenter size-full wp-image-412" /></a></p>
<p>If you want to make a field required just for a particular form, you can use a form onload event to change the requirement level.  One of the great things about CRM 2011 is just how much is exposed to JScript through Xrm.Page.  There are <a href="http://msdn.microsoft.com/en-us/library/gg334409.aspx">methods on the attribute</a> to <a href="http://msdn.microsoft.com/en-us/library/gg334409.aspx#BKMK_getRequiredLevel">get the required level</a> and <a href="http://msdn.microsoft.com/en-us/library/gg334409.aspx#BKMK_setRequiredLevel">set the required level</a>.  Let&#8217;s suppose for example that we want to make the First Name required, but only on this form, then we could use the following onload function with the parameters &#8216;required&#8217;, &#8216;firstname&#8217; to make the field required.  If we needed to add multiple fields, then we would just specify them after &#8216;firstname&#8217;, such as &#8216;required&#8217;,'firstname&#8217;,'address1_city&#8217;.</p>
<pre name="code" class="javascript">
function updateRequirementLevel()
{
    var level = arguments[0];
    for (var i=1; i < arguments.length; i++)
    {
        var attribute = Xrm.Page.data.entity.attributes.get(arguments[i]);
        attribute.setRequiredLevel(level);
    }
}
</pre>
<p>That will make each field you specify after the level, required or recommended based on the level you pass as the first parameter.  Calling the function updateRequirementLevel('required','firstname'); will make the firstname required.</p>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://mscrmblogger.com/2011/04/10/crm-2011-required-fields/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>CRM 2011: Change CRM Address State to a drop-down</title>
		<link>http://mscrmblogger.com/2011/03/07/crm-2011-change-crm-address-state-to-a-drop-down/</link>
		<comments>http://mscrmblogger.com/2011/03/07/crm-2011-change-crm-address-state-to-a-drop-down/#comments</comments>
		<pubDate>Mon, 07 Mar 2011 15:01:33 +0000</pubDate>
		<dc:creator>Carlton Colter</dc:creator>
				<category><![CDATA[Extensions]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Web Resources]]></category>
		<category><![CDATA[address]]></category>
		<category><![CDATA[contact]]></category>
		<category><![CDATA[crm]]></category>
		<category><![CDATA[crm 2011]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jscript]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Microsoft Dynamics CRM 2011]]></category>
		<category><![CDATA[onload event]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://mscrmblogger.com/?p=338</guid>
		<description><![CDATA[<p><b>Do you want a drop down box for the state, but you don't want to break core CRM functionality?</b></p>
<p>In CRM 4.0 I had posted an article about <a href="http://mscrmblogger.com/2009/05/11/change-crm-address-state-to-a-drop-down-box/">changing the CRM Address State to a drop down box</a>.  I have went back and updated the code a little (fixed a bug) and it will work with CRM 2011.</p>
<p>Ok, this script uses the same methods I used in CRM 4 to show the states for the United States and Canada (You can always modify it to have more options).  This will help restrict what people put in the state field by providing them a drop down box.  It will also allow them to view the old text box and enter any custom information just by clicking on '* ENTER A CUSTOM PROVINCE *'.</p>
<p>This script will work on the onload for a lead, contact, account, and sales-contact.</p>]]></description>
			<content:encoded><![CDATA[<p><b>This page is nolonger current.  Please view: <a href="http://mscrmblogger.com/2011/05/11/crm-2011-making-the-state-field-a-drop-down/">http://mscrmblogger.com/2011/05/11/crm-2011-making-the-state-field-a-drop-down/</a></b></p>
<p><b>Do you want a drop down box for the state, but you don&#8217;t want to break core CRM functionality?</b></p>
<p>In CRM 4.0 I had posted an article about <a href="http://mscrmblogger.com/2009/05/11/change-crm-address-state-to-a-drop-down-box/">changing the CRM Address State to a drop down box</a>.  I have went back and updated the code a little (fixed a bug) and it will work with CRM 2011.</p>
<p>Ok, this script uses the same methods I used in CRM 4 to show the states for the United States and Canada (You can always modify it to have more options).  This will help restrict what people put in the state field by providing them a drop down box.  It will also allow them to view the old text box and enter any custom information just by clicking on &#8216;* ENTER A CUSTOM PROVINCE *&#8217;.</p>
<p>This script will work on the onload for a lead, contact, account, and sales-contact.</p>
<p>This script does use the _d html objects, which, to my knowledge is considered unsupported in CRM 2011.  CRM 2011 does expose these data elements and control elements using Xrm.Page and this script doesn&#8217;t use them, and I may come back and update this script, but since it works in CRM 4 and in CRM 2011, I figured I&#8217;d repost it.</p>
<p><b>StateDropDown.js Jscript Code:</b></p>
<pre name="code" class="javascript">
function ddlState ()
{

    // Get the state or province cell.
    var provinceid = 'stateorprovince';
    var statecell = document.getElementById(provinceid + '_d');

    if (!statecell)
    {
        provinceid = 'address1_stateorprovince';
        statecell = document.getElementById(provinceid + '_d');
    }

    var stateobject = document.getElementById(provinceid);
    stateobject.style.display = 'none';

    var statevalue = stateobject.value;

    var ddl = document.createElement('select');
    ddl.setAttribute('id','new_stateorprovince');
    ddl.setAttribute('class','ms-crm-SelectBox');
    ddl.setAttribute('req','2');
    ddl.setAttribute('height','4');
    ddl.setAttribute('style','IME-MODE: auto');

    // Build some lists.
    var CStateName = new Array();
    var CStateAbbr = new Array();
    var USStateName = new Array();
    var USStateAbbr = new Array();

    // If nothing is entered for state, show SELECT A STATE
    var found=false;
    if (statevalue.length&lt;1)
    {
        stateoption=document.createElement('option');
        stateoption.setAttribute('value','');
        stateoption.innerHTML = ' ** SELECT A STATE ** ';
        ddl.appendChild(stateoption);
        found=true;
    }

    // Build Canada Array
    CStateName[0]  = "Alberta";                   CStateAbbr[0]  = "AB";
    CStateName[1]  = "British Columbia";          CStateAbbr[1]  = "BC";
    CStateName[2]  = "Manitoba";                  CStateAbbr[2]  = "MB";
    CStateName[3]  = "New Brunswick";             CStateAbbr[3]  = "NB";
    CStateName[4]  = "Newfoundland and Labrador"; CStateAbbr[4]  = "NL";
    CStateName[5]  = "Northwest Territories";     CStateAbbr[5]  = "NT";
    CStateName[6]  = "Nova Scotia";               CStateAbbr[6]  = "NS";
    CStateName[7]  = "Nunavut";                   CStateAbbr[7]  = "NU";
    CStateName[8]  = "Ontario";                   CStateAbbr[8]  = "ON";
    CStateName[9]  = "Prince Edward Island";      CStateAbbr[9]  = "PE";
    CStateName[10] = "Quebec";                    CStateAbbr[10] = "QC";
    CStateName[11] = "Saskatchewan";              CStateAbbr[11] = "SK";
    CStateName[12] = "Yukon";                     CStateAbbr[12] = "YT";

    // Build US Array
    USStateName[0]  = "Alabama";        USStateAbbr[0]  = "AL";
    USStateName[1]  = "Alaska";         USStateAbbr[1]  = "AK";
    USStateName[2]  = "Arizona";        USStateAbbr[2]  = "AZ";
    USStateName[3]  = "Arkansas";       USStateAbbr[3]  = "AR";
    USStateName[4]  = "California";     USStateAbbr[4]  = "CA";
    USStateName[5]  = "Colorado";       USStateAbbr[5]  = "CO";
    USStateName[6]  = "Connecticut";    USStateAbbr[6]  = "CT";
    USStateName[7]  = "District of Columbia"; USStateAbbr[7]  = "DC";
    USStateName[8]  = "Delaware";       USStateAbbr[8]  = "DE";
    USStateName[9]  = "Florida";        USStateAbbr[9]  = "FL";
    USStateName[10]  = "Georgia";       USStateAbbr[10]  = "GA";
    USStateName[11] = "Hawaii";         USStateAbbr[11] = "HI";
    USStateName[12] = "Idaho";          USStateAbbr[12] = "ID";
    USStateName[13] = "Illinois";       USStateAbbr[13] = "IL";
    USStateName[14] = "Indiana";        USStateAbbr[14] = "IN";
    USStateName[15] = "Iowa";           USStateAbbr[15] = "IA";
    USStateName[16] = "Kansas";         USStateAbbr[16] = "KS";
    USStateName[17] = "Kentucky";       USStateAbbr[17] = "KY";
    USStateName[18] = "Louisiana";      USStateAbbr[18] = "LA";
    USStateName[19] = "Maine";          USStateAbbr[19] = "ME";
    USStateName[20] = "Maryland";       USStateAbbr[20] = "MD";
    USStateName[21] = "Massachusetts";  USStateAbbr[21] = "MA";
    USStateName[22] = "Michigan";       USStateAbbr[22] = "MI";
    USStateName[23] = "Minnesota";      USStateAbbr[23] = "MN";
    USStateName[24] = "Mississippi";    USStateAbbr[24] = "MS";
    USStateName[25] = "Missouri";       USStateAbbr[25] = "MO";
    USStateName[26] = "Montana";        USStateAbbr[26] = "MT";
    USStateName[27] = "Nebraska";       USStateAbbr[27] = "NE";
    USStateName[28] = "Nevada";         USStateAbbr[28] = "NV";
    USStateName[29] = "New Hampshire";  USStateAbbr[29] = "NH";
    USStateName[30] = "New Jersey";     USStateAbbr[30] = "NJ";
    USStateName[31] = "New Mexico";     USStateAbbr[31] = "NM";
    USStateName[32] = "New York";       USStateAbbr[32] = "NY";
    USStateName[33] = "North Carolina"; USStateAbbr[33] = "NC";
    USStateName[34] = "North Dakota";   USStateAbbr[34] = "ND";
    USStateName[35] = "Ohio";           USStateAbbr[35] = "OH";
    USStateName[36] = "Oklahoma";       USStateAbbr[36] = "OK";
    USStateName[37] = "Oregon";         USStateAbbr[37] = "OR";
    USStateName[38] = "Pennsylvania";   USStateAbbr[38] = "PA";
    USStateName[39] = "Rhode Island";   USStateAbbr[39] = "RI";
    USStateName[40] = "South Carolina"; USStateAbbr[40] = "SC";
    USStateName[41] = "South Dakota";   USStateAbbr[41] = "SD";
    USStateName[42] = "Tennessee";      USStateAbbr[42] = "TN";
    USStateName[43] = "Texas";          USStateAbbr[43] = "TX";
    USStateName[44] = "Utah";           USStateAbbr[44] = "UT";
    USStateName[45] = "Vermont";        USStateAbbr[45] = "VT";
    USStateName[46] = "Virginia";       USStateAbbr[46] = "VA";
    USStateName[47] = "Washington";     USStateAbbr[47] = "WA";
    USStateName[48] = "West Virginia";  USStateAbbr[48] = "WV";
    USStateName[49] = "Wisconsin";      USStateAbbr[49] = "WI";
    USStateName[50] = "Wyoming";        USStateAbbr[50] = "WY";

    // Build the drop down
    var stateoption;
    stateoption=document.createElement('option');
    stateoption.setAttribute('value','');
    stateoption.innerHTML = '---United States--------';
    ddl.appendChild(stateoption);

    var i=0;
    for(i=0;i&lt;USStateName.length;i++)
    {
        stateoption=document.createElement('option');
        stateoption.setAttribute('value',USStateAbbr[i]);
        if (USStateAbbr[i]==statevalue)
        {
            stateoption.setAttribute('selected','selected');
            found = true;
        }
        stateoption.innerHTML = USStateAbbr[i] +
        ' (' + USStateName[i] + ')';
        ddl.appendChild(stateoption);
    }

    stateoption=document.createElement('option');
    stateoption.setAttribute('value','');
    stateoption.innerHTML = '---Canada---------------';
    ddl.appendChild(stateoption);

    var i=0;
    for(i=0;i&lt;CStateName.length;i++)
    {
        stateoption=document.createElement('option');
        stateoption.setAttribute('value',CStateAbbr[i]);
        if (CStateAbbr[i]==statevalue)
        {
            stateoption.setAttribute('selected','selected');
            found = true;
        }
        stateoption.innerHTML = CStateAbbr[i] + ' (' + CStateName[i] + ')';
        ddl.appendChild(stateoption);
    }

    stateoption=document.createElement('option');
    stateoption.setAttribute('value','customselection');
    stateoption.innerHTML = ' ** ENTER A CUSTOM PROVINCE ** ';

    if (found==false)
    {
        stateoption=document.createElement('option');
        stateoption.setAttribute('value',statevalue);
        stateoption.setAttribute('selected','selected');
        stateoption.innerHTML = statevalue + ' (Custom)';
        ddl.appendChild(stateoption);
    }

    ddl.appendChild(stateoption);

    // Add the drop down and size accordingly.
    statecell.appendChild(ddl);
    ddl.onchange = textState;
    ddl.style.width = '100%';
}

function textState()
{
    // Find drop down and real textbox
    provinceid = 'stateorprovince';

    var stateobject = document.getElementById(provinceid);
    if (!stateobject)
    {
        provinceid = 'address1_stateorprovince';
        stateobject = document.getElementById(provinceid);
    }
    var ddl = document.getElementById('new_stateorprovince');

    // if dropdown value is customselection, show real textbox
    if (ddl.value=='customselection')
    {
        // Get the state or province cell.
        var statecell = document.getElementById(provinceid + '_d');
        statecell.removeChild(ddl);
        stateobject.style.display = 'inline';
    } else {
        // if dropdown is not customselection,
        // put value from ddl into real textbox.
        stateobject.value = ddl.value;
    }

}
</pre>
<p>Then in the form&#8217;s onload event, just add the method <b>ddlState</b> with no parameters.</p>
]]></content:encoded>
			<wfw:commentRss>http://mscrmblogger.com/2011/03/07/crm-2011-change-crm-address-state-to-a-drop-down/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

