<?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; jscript</title>
	<atom:link href="http://mscrmblogger.com/tag/jscript/feed/" rel="self" type="application/rss+xml" />
	<link>http://mscrmblogger.com</link>
	<description>Achieving it all with Microsoft Dynamics CRM™</description>
	<lastBuildDate>Wed, 30 Nov 2011 00:34:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<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>2</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());
  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>4</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>6</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>CRM 2011: Making the state field a drop down</title>
		<link>http://mscrmblogger.com/2011/05/11/crm-2011-making-the-state-field-a-drop-down/</link>
		<comments>http://mscrmblogger.com/2011/05/11/crm-2011-making-the-state-field-a-drop-down/#comments</comments>
		<pubDate>Wed, 11 May 2011 16:08:12 +0000</pubDate>
		<dc:creator>Carlton Colter</dc:creator>
				<category><![CDATA[Extensions]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Web Resources]]></category>
		<category><![CDATA[crm 2011]]></category>
		<category><![CDATA[dropdown]]></category>
		<category><![CDATA[editable dropdown]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jscript]]></category>
		<category><![CDATA[microsoft dynamics crm]]></category>
		<category><![CDATA[Microsoft Dynamics CRM 2011]]></category>
		<category><![CDATA[state]]></category>
		<category><![CDATA[stateorprovince]]></category>
		<category><![CDATA[Web Resource]]></category>

		<guid isPermaLink="false">http://mscrmblogger.com/?p=456</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 had modified the script to work with CRM 2011, but it was still unsupported and some people had problems making it work on other entities.  This version uses an HTML web resource and uses all supported methods.</p>]]></description>
			<content:encoded><![CDATA[<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>.  While I had gone back and updated the code to work with CRM 2011, some people still had problems using it.  Also, it wasn&#8217;t the best way to do it in CRM 2011.  With the web-resources in CRM 2011 there is a completely supported way of creating a state drop down!</p>
<p>You can use an html web-resource!  Below is the source for the html web resource, then you just need to hide the state drop down on your form and add the web resource and set the data parameter to the field id, such as address1_stateorprovince.</p>
<p>This helps by providing a set of default option in a drop-down box.  It also supports (** Other) which will show a text box for entering something not in the drop down.  This web-resource works on any entity where you need a state drop down.</p>
<p><b>Here is the configuration for the HTML Web Resource on the Contact form:</b></p>
<div id="attachment_473" class="wp-caption aligncenter" style="width: 794px"><a href="http://mscrmblogger.com/wp-content/uploads/2011/05/statedropdown-resource-properties.png"><img src="http://mscrmblogger.com/wp-content/uploads/2011/05/statedropdown-resource-properties.png" alt="State Drop Down Web Resource Properties" title="State Drop Down Web Resource Properties" width="784" height="597" class="size-full wp-image-473" /></a><p class="wp-caption-text">State Drop Down Web Resource Properties</p></div>
<p><b>StateDropDown.html:</b></p>
<pre name="code" class="html">
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;State Drop Down&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 datafield;
function getQuerystring(key)
{
    var work = key.replace(/[\[]/,&quot;\\\[&quot;).replace(/[\]]/,&quot;\\\]&quot;);
    var regex = new RegExp(&quot;[\\?&amp;]&quot;+work+&quot;=([^&amp;#]*)&quot;);
    var qs = regex.exec(window.location.href);
    if (qs == null) return null;
    return qs[1];
}

function onLoad()
{
    var updatefield = getQuerystring(&quot;data&quot;);
    datafield = parent.Xrm.Page.data.entity.attributes.get(updatefield);
    var value = datafield.getValue();
    var dropdown = document.getElementById(&quot;custom_state&quot;);

    // fix for outlook issue identified by Ryan
    // do not pass null value to IsOptionInDropDown
    if (value==null || value==&quot;&quot;) {
        dropdown.value = &quot;!1&quot;; // Set to select a state by default
        return; // stop processing - empty value
    }

    // If it is a dropdown value, set the dropdown and exit onload
    if (IsOptionInDropDown(value)) return;

    // no value found for drop down, value is not null or empty, therefor set other
    dropdown.value = &quot;other&quot;;
    var other = document.getElementById(&quot;other_state&quot;);
    other.value = value;
    SetOtherVisible(true);
}

function IsOptionInDropDown(value)
{
    // Replace fixes for common name variants
    switch (value) {
        case "d.c.": value="dc";
            break;
        default:
            break;
    }

    // Change to lowercase
    var lvalue=value.toLowerCase();

    var dropdown = document.getElementById("custom_state");
    var options = dropdown.options;
    var i = 0;
    for(i=0;i&lt;options .length;i++)
    {
        if (options[i].value.toLowerCase() == lvalue || options[i].text.toLowerCase() == lvalue)
        {
            dropdown.value = options[i].value;
            SetOtherVisible(false);
            return true;
        }
    }
    return false;
}

function DropDownChanged(value)
{
    if (value !== null &amp;&amp; value!==&quot;&quot;) {
        if (value.charAt(0)=='!') { // Fixed By Joseph Martine - charAt or substring not [0]
            StateChanged(&quot;&quot;);// Fixed By Joseph Martine
            return;
        }
        if (value==&quot;other&quot;) {
            SetOtherVisible(true);
            return;
        } else {
            SetOtherVisible(false); // Fixed By Joseph Martine
        }
        var os = document.getElementById(&quot;other_state&quot;);
        os.value = value;
        StateChanged(value);
    }
}

function TextBoxChanged(value)
{
    StateChanged(value);
    IsOptionInDropDown(value); // This also updates the visible in its check...
    return true;
}

function StateChanged(value)
{
    // Update Xrm.Page data field
    datafield.setValue(value);
}

function SetOtherVisible(visibility)
{
    var ddcell = document.getElementById(&quot;cell_dd&quot;);
    var textcell = document.getElementById(&quot;cell_tb&quot;);
    if (visibility) {
        ddcell.style.width=&quot;50%&quot;;
        textcell.style.display=&quot;table-cell&quot;;
        textcell.style.width=&quot;50%&quot;;
    } else {
        textcell.style.display=&quot;none&quot;;
        ddcell.style.width=&quot;100%&quot;;
        textcell.style.width=&quot;100%&quot;;
    }
}

&lt;/script&gt;
&lt;/head&gt;
&lt;body onload=&quot;onLoad();&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; width=&quot;100%&quot;&gt;&lt;tr&gt;&lt;td id=&quot;cell_dd&quot;&gt;
&lt;select name=&quot;custom_state&quot; req=&quot;2&quot; height=&quot;4&quot; style=&quot;IME-MODE: auto;width:100%;&quot;
class=&quot;ms-crm-SelectBox&quot; id=&quot;custom_state&quot; onChange=&quot;DropDownChanged(this.value)&quot;&gt;
    &lt;option value=&quot;!1&quot;&gt;---Select a State-------&lt;/option&gt;
    &lt;option value=&quot;!2&quot;&gt;---Canada---------------&lt;/option&gt;
    &lt;option value=&quot;AB&quot;&gt;Alberta&lt;/option&gt;
    &lt;option value=&quot;BC&quot;&gt;British Columbia&lt;/option&gt;
    &lt;option value=&quot;MB&quot;&gt;Manitoba&lt;/option&gt;
    &lt;option value=&quot;NB&quot;&gt;New Brunswick&lt;/option&gt;
    &lt;option value=&quot;NL&quot;&gt;Newfoundland and Labrador&lt;/option&gt;
    &lt;option value=&quot;NT&quot;&gt;Northwest Territories&lt;/option&gt;
    &lt;option value=&quot;NS&quot;&gt;Nova Scotia&lt;/option&gt;
    &lt;option value=&quot;NU&quot;&gt;Nunavut&lt;/option&gt;
    &lt;option value=&quot;ON&quot;&gt;Ontario&lt;/option&gt;
    &lt;option value=&quot;PE&quot;&gt;Prince Edward Island&lt;/option&gt;
    &lt;option value=&quot;QC&quot;&gt;Quebec&lt;/option&gt;
    &lt;option value=&quot;SK&quot;&gt;Saskatchewan&lt;/option&gt;
    &lt;option value=&quot;YT&quot;&gt;Yukon&lt;/option&gt;
  &lt;option value=&quot;!3&quot;&gt;---United States--------&lt;/option&gt;
    &lt;option value=&quot;AL&quot;&gt;Alabama&lt;/option&gt;
    &lt;option value=&quot;AK&quot;&gt;Alaska&lt;/option&gt;
    &lt;option value=&quot;AZ&quot;&gt;Arizona&lt;/option&gt;
    &lt;option value=&quot;AR&quot;&gt;Arkansas&lt;/option&gt;
    &lt;option value=&quot;CA&quot;&gt;California&lt;/option&gt;
    &lt;option value=&quot;CO&quot;&gt;Colorado&lt;/option&gt;
    &lt;option value=&quot;CT&quot;&gt;Connecticut&lt;/option&gt;
    &lt;option value=&quot;DC&quot;&gt;District of Columbia&lt;/option&gt;
    &lt;option value=&quot;DE&quot;&gt;Delaware&lt;/option&gt;
    &lt;option value=&quot;FL&quot;&gt;Florida&lt;/option&gt;
    &lt;option value=&quot;GA&quot;&gt;Georgia&lt;/option&gt;
    &lt;option value=&quot;HI&quot;&gt;Hawaii&lt;/option&gt;
    &lt;option value=&quot;ID&quot;&gt;Idaho&lt;/option&gt;
    &lt;option value=&quot;IL&quot;&gt;Illinois&lt;/option&gt;
    &lt;option value=&quot;IN&quot;&gt;Indiana&lt;/option&gt;
    &lt;option value=&quot;IA&quot;&gt;Iowa&lt;/option&gt;
    &lt;option value=&quot;KS&quot;&gt;Kansas&lt;/option&gt;
    &lt;option value=&quot;KY&quot;&gt;Kentucky&lt;/option&gt;
    &lt;option value=&quot;LA&quot;&gt;Louisiana&lt;/option&gt;
    &lt;option value=&quot;ME&quot;&gt;Maine&lt;/option&gt;
    &lt;option value=&quot;MD&quot;&gt;Maryland&lt;/option&gt;
    &lt;option value=&quot;MA&quot;&gt;Massachusetts&lt;/option&gt;
    &lt;option value=&quot;MI&quot;&gt;Michigan&lt;/option&gt;
    &lt;option value=&quot;MN&quot;&gt;Minnesota&lt;/option&gt;
    &lt;option value=&quot;MS&quot;&gt;Mississippi&lt;/option&gt;
    &lt;option value=&quot;MO&quot;&gt;Missouri&lt;/option&gt;
    &lt;option value=&quot;MT&quot;&gt;Montana&lt;/option&gt;
    &lt;option value=&quot;NE&quot;&gt;Nebraska&lt;/option&gt;
    &lt;option value=&quot;NV&quot;&gt;Nevada&lt;/option&gt;
    &lt;option value=&quot;NH&quot;&gt;New Hampshire&lt;/option&gt;
    &lt;option value=&quot;NJ&quot;&gt;New Jersey&lt;/option&gt;
    &lt;option value=&quot;NM&quot;&gt;New Mexico&lt;/option&gt;
    &lt;option value=&quot;NY&quot;&gt;New York&lt;/option&gt;
    &lt;option value=&quot;NC&quot;&gt;North Carolina&lt;/option&gt;
    &lt;option value=&quot;ND&quot;&gt;North Dakota&lt;/option&gt;
    &lt;option value=&quot;OH&quot;&gt;Ohio&lt;/option&gt;
    &lt;option value=&quot;OK&quot;&gt;Oklahoma&lt;/option&gt;
    &lt;option value=&quot;OR&quot;&gt;Oregon&lt;/option&gt;
    &lt;option value=&quot;PA&quot;&gt;Pennsylvania&lt;/option&gt;
    &lt;option value=&quot;RI&quot;&gt;Rhode Island&lt;/option&gt;
    &lt;option value=&quot;SC&quot;&gt;South Carolina&lt;/option&gt;
    &lt;option value=&quot;SD&quot;&gt;South Dakota&lt;/option&gt;
    &lt;option value=&quot;TN&quot;&gt;Tennessee&lt;/option&gt;
    &lt;option value=&quot;TX&quot;&gt;Texas&lt;/option&gt;
    &lt;option value=&quot;UT&quot;&gt;Utah&lt;/option&gt;
    &lt;option value=&quot;VT&quot;&gt;Vermont&lt;/option&gt;
    &lt;option value=&quot;VA&quot;&gt;Virginia&lt;/option&gt;
    &lt;option value=&quot;WA&quot;&gt;Washington&lt;/option&gt;
    &lt;option value=&quot;WV&quot;&gt;West Virginia&lt;/option&gt;
    &lt;option value=&quot;WI&quot;&gt;Wisconsin&lt;/option&gt;
    &lt;option value=&quot;WY&quot;&gt;Wyoming&lt;/option&gt;
    &lt;option value=&quot;other&quot;&gt;** Other&lt;/option&gt;
&lt;/select&gt;
&lt;/td&gt;&lt;td id=&quot;cell_tb&quot; style=&quot;padding-left:15px;display:none;&quot;&gt;
&lt;input class=&quot;ms-crm-Text&quot; style=&quot;ime-mode: auto;width:100%;&quot; type=&quot;text&quot;
maxLength=&quot;50&quot; id=&quot;other_state&quot; req=&quot;0&quot; onChange=&quot;TextBoxChanged(this.value);&quot; /&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://mscrmblogger.com/2011/05/11/crm-2011-making-the-state-field-a-drop-down/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>SilverCrmSoap: A Silverlight CRM Soap Library for CRM 2011</title>
		<link>http://mscrmblogger.com/2011/04/26/silvercrmsoap-a-silverlight-crm-soap-library-for-crm-2011/</link>
		<comments>http://mscrmblogger.com/2011/04/26/silvercrmsoap-a-silverlight-crm-soap-library-for-crm-2011/#comments</comments>
		<pubDate>Tue, 26 Apr 2011 17:56:11 +0000</pubDate>
		<dc:creator>Carlton Colter</dc:creator>
				<category><![CDATA[Extensions]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Web Resources]]></category>
		<category><![CDATA[crm]]></category>
		<category><![CDATA[crm 2011]]></category>
		<category><![CDATA[crm sdk]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jscript]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Microsoft Dynamics CRM 2011]]></category>

		<guid isPermaLink="false">http://mscrmblogger.com/?p=421</guid>
		<description><![CDATA[<p>SilverCrmSoap is a library built using the methods in <a href="http://msdn.microsoft.com/en-us/library/gg594452.aspx">Walkthrough: Use the SOAP Endpoint for Web Resources with Silverlight</a>. The SilverCrmSoap library simplifies SOAP Silverlight development for CRM 2011 by providing a class that does a lot of the heavy lifting right out of the box.</p>
<p>You can check out the SilverCrmSoap library on <a href="http://silvercrmsoap.codeplex.com/">CodePlex</a> or read more about it on the <a href="http://blogs.msdn.com/b/crm/archive/2011/04/26/silvercrmsoap-a-crm-soap-library-for-crm-2011.aspx">CRM Team Blog</a>.</p>]]></description>
			<content:encoded><![CDATA[<p>SilverCrmSoap is a library built using the methods in <a href="http://msdn.microsoft.com/en-us/library/gg594452.aspx">Walkthrough: Use the SOAP Endpoint for Web Resources with Silverlight</a>. The SilverCrmSoap library simplifies SOAP Silverlight development for CRM 2011 by providing a class that does a lot of the heavy lifting right out of the box.</p>
<p>In essence, the SilverCrmSoap library objectifies FetchXml allowing you to modify it easily in code, adds an XrmHelper for calling the context and page functions from a Silverlight application, a FormHelper for setting values on a form, and a SoapHelper for making all of your SOAP calls.  It becomes a real time saver because you don&#8217;t have to recompile it.  And, if your curious where/when to use it, it&#8217;s pretty straight forward.  If you need SOAP for CRM, then use the library and save time.</p>
<p>How do you know to use SOAP vs REST?</p>
<p><b>Use SOAP when&#8230;</b></p>
<ul>
<li>You need to use late binding to create a dynamic Silverlight application that works with any (or multiple) entities.</li>
<li>You need to execute a message.</li>
<li>You need to assign records.</li>
<li>You need to retrieve metadata.</li>
</ul>
<p>There are benefits to using the REST endpoint too, and being able to quickly leverage both end points in a project can be extremely helpful.</p>
<p><b>Use REST when&#8230;</b></p>
<ul>
<li>You need to early bind to objects.</li>
<li>You want to leverage LINQ with the early bound objects.</li>
<li>You want compile time type support and IntelliSense.</li>
</ul>
<p>You can check out the SilverCrmSoap library on <a href="http://silvercrmsoap.codeplex.com/">CodePlex</a> or read more about it on the <a href="http://blogs.msdn.com/b/crm/archive/2011/04/26/silvercrmsoap-a-crm-soap-library-for-crm-2011.aspx">CRM Team Blog</a>.</p>
<p>Enjoy!</p>
<p>-MSCRMBlogger</p>
]]></content:encoded>
			<wfw:commentRss>http://mscrmblogger.com/2011/04/26/silvercrmsoap-a-silverlight-crm-soap-library-for-crm-2011/feed/</wfw:commentRss>
		<slash:comments>0</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.</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>5</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>
		<item>
		<title>CRM 2011: Toggle Visibility (Hide/Show) &#8211; Visibility.js</title>
		<link>http://mscrmblogger.com/2011/02/24/crm-2011-toggle-visibility/</link>
		<comments>http://mscrmblogger.com/2011/02/24/crm-2011-toggle-visibility/#comments</comments>
		<pubDate>Thu, 24 Feb 2011 22:57:49 +0000</pubDate>
		<dc:creator>Carlton Colter</dc:creator>
				<category><![CDATA[Extensions]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Web Resources]]></category>
		<category><![CDATA[crm]]></category>
		<category><![CDATA[crm 2011]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jscript]]></category>
		<category><![CDATA[Microsoft Dynamics CRM 2011]]></category>
		<category><![CDATA[onchange]]></category>
		<category><![CDATA[onload event]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[toggle field]]></category>
		<category><![CDATA[visibility]]></category>

		<guid isPermaLink="false">http://mscrmblogger.com/?p=314</guid>
		<description><![CDATA[Visibility.js provides a simple way to set the visibility of navigation, section, tab, and form control elements using JScript.  It also allows you to change the visibility using the onClick event of a checkbox.]]></description>
			<content:encoded><![CDATA[<p>Often times we need to toggle the visiblity of an element based on the value of a field.  This JScript file adds the methods to accomplish this by calling the setVisibility function.  For example, in an onChange event for new_mypicklist I can call:</p>
<pre name="code" class="javascript">
setVisibility('section','new_mypicklist','section_main',42);
</pre>
<p>This hides the section_main section if the value is not 42, which simplifies the process of hiding and showing relevant information.</p>
<p>I also like to use checkboxes to handle the visibility of elements, but checkbox values dont&#8217; change until they lose focus.  To work around the issue, I register an onClick event during the form load instead of using the onChange event.  This unsupported method allows me to modify the value onClick and change the visibility immediately.  To use this I just need to call it in the onload:</p>
<pre name="code" class="javascript">
registerToggle('section', 'new_checkbox', 'section_main');
</pre>
<p>If you wanted to hide it when new_checkbox was false (or no), then you would need to specify the value, 0.</p>
<pre name="code" class="javascript">
registerToggle('section', 'new_checkbox', 'section_main',0);
</pre>
<p><b>JScript: visibility.js</b></p>
<p>This is the main javascript file&#8230; visibility.js that you would need to add and reference as a web resource in CRM 2011, everything except for the registerToggle uses supported methods.</p>
<pre name="code" class="javascript">
function registerToggle(t, attr, c, v) {
    if (typeof (v) === &quot;undefined&quot; || v === null) {
        var v = 1;
    }
    var ctrl = Xrm.Page.ui.controls.get(attr);
    var a = ctrl.getAttribute();
    var el = document.getElementById(attr);

    // Build Toggle Function
    var f = &quot;var ef=function() { &quot; +
              &quot;var a = Xrm.Page.data.entity.attributes.get(attr); &quot; +
              &quot;a.setValue(!a.getValue()); &quot; +
              &quot;setVisibility('&quot; + t + &quot;','&quot; + attr + &quot;','&quot; + c + &quot;',&quot; + v + &quot;);&quot; +
              &quot; };&quot;&#59;

    eval(f);

    // Attach to click event
    el.attachEvent('onclick', ef, false);

    // Set visibility
    setVisibility(t, attr, c, v);
}

function setVisibility(t, attr, c, v) {
    switch (t.toLowerCase().charAt(0)) {
        //tab
        case 't': setTabVisibility(attr, c, v);
            break;
        //section
        case 's': setSectionVisibility(attr, c, v);
            break;
        //control
        case 'c': setControlVisibility(attr, c, v);
            break;
        //navigation
        case 'n': setNavigationVisibility(attr, c, v);
            break;
    }
}

function setNavigationVisibility(attributename, navitemname, value) {
    var attribute = Xrm.Page.data.entity.attributes.get(attributename);
    var navitem = Xrm.Page.ui.navigation.items.get(navitemname);
    if (navitem === null)
    {
        return;
    }
    navitem.setVisible(attribute.getValue() == value);
}

function setTabVisibility(attributename, tabname, value) {
    var attribute = Xrm.Page.data.entity.attributes.get(attributename);
    var tab = Xrm.Page.ui.tabs.get(tabname);
    if (tab === null)
    {
        return;
    }
    tab.setVisible(attribute.getValue() == value);
}

function setSectionVisibility(attributename, sectionname, value) {
    var attribute = Xrm.Page.data.entity.attributes.get(attributename);
    var tabs = Xrm.Page.ui.tabs.get();
    for(var i in tabs) {
        var tab = tabs[i];
        var section = tab.sections.get(sectionname);
        if (section !== null) {
            section.setVisible(attribute.getValue() == value);
            return;
        }
    }
}

function setControlVisibility(attributename, controlname, value) {
    var attribute = Xrm.Page.data.entity.attributes.get(attributename);
    var control = Xrm.Page.ui.controls.get(controlname);
    if (control === null)
    {
        return;
    }
    control.setVisible(attribute.getValue() == value);
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://mscrmblogger.com/2011/02/24/crm-2011-toggle-visibility/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
	</channel>
</rss>

