<?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; Integration</title>
	<atom:link href="http://mscrmblogger.com/category/integration-integration/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>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>Workflow: Geocode (and correct) Addresses with Bing Maps</title>
		<link>http://mscrmblogger.com/2010/05/20/geocode_with_bing/</link>
		<comments>http://mscrmblogger.com/2010/05/20/geocode_with_bing/#comments</comments>
		<pubDate>Thu, 20 May 2010 17:59:03 +0000</pubDate>
		<dc:creator>Carlton Colter</dc:creator>
				<category><![CDATA[Extensions]]></category>
		<category><![CDATA[Integration]]></category>
		<category><![CDATA[Scoperta]]></category>
		<category><![CDATA[Workflow]]></category>
		<category><![CDATA[address]]></category>
		<category><![CDATA[bing]]></category>
		<category><![CDATA[bing maps]]></category>
		<category><![CDATA[crm]]></category>
		<category><![CDATA[crm 4]]></category>
		<category><![CDATA[crm4]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[custom workflow]]></category>
		<category><![CDATA[geocode]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[microsoft dynamics CRM 4]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[workflow]]></category>

		<guid isPermaLink="false">http://mscrmblogger.com/?p=221</guid>
		<description><![CDATA[Bing Maps are great.  You can geocode and correct your addresses.  While this isn't anything complicated, it is a good example of a custom workflow that uses an external webservice.]]></description>
			<content:encoded><![CDATA[<p>Bing Maps are great.  You can geocode and correct your addresses.  Depending on your level of queries and types of usage you may need to purchase credits to query Bing Maps, but I thought it was pretty straight forward. If you need to get a Bing Maps account, go <a href="http://www.microsoft.com/maps/developers/">here</a>.</p>
<p>The thing that makes this great is it is workflow.  It is not tied down to an entity.  You can use it on your custom entities, you can geocode your addresses, and correct them.  You can do address verification and geocoding.  You can control what you do using workflow.
</p>
<p>Ok, while this isn&#8217;t anything complicated, I thought it was a good example of a custom workflow that used an external webservice.  <i>Please don&#8217;t forget to create a signed key for your project.</i></p>
<p><b>Workflow Class:</b></p>
<pre name="code" class="csharp">
using System;
using System.ServiceModel;
using System.Text;
using System.Workflow.Activities;
using System.Workflow.ComponentModel;
using BingWorkflow.BingMapsGeo;
using Microsoft.Crm.Sdk;
using Microsoft.Crm.Workflow;
using Microsoft.Win32;

namespace BingWorkflow
{
    [CrmWorkflowActivity("Bing Maps", "Geocode")]
    public class VerifyAddressUsingBingMapsActivity :
        SequenceActivity
    {
        // Activity code goes here. 

        public static DependencyProperty AddressCityProperty = DependencyProperty.Register(
            "AddressCity", typeof (string), typeof (VerifyAddressUsingBingMapsActivity));

        public static DependencyProperty AddressCountryProperty = DependencyProperty.Register(
            "AddressCountry", typeof (string), typeof (VerifyAddressUsingBingMapsActivity));

        public static DependencyProperty AddressLine1Property = DependencyProperty.Register(
            "AddressLine1", typeof (string), typeof (VerifyAddressUsingBingMapsActivity));

        public static DependencyProperty AddressPostalCodeProperty = DependencyProperty.Register(
            "AddressPostalCode", typeof (string), typeof (VerifyAddressUsingBingMapsActivity));

        public static DependencyProperty AddressStateProperty = DependencyProperty.Register(
            "AddressState", typeof (string), typeof (VerifyAddressUsingBingMapsActivity));

        public static DependencyProperty BingKeyProperty = DependencyProperty.Register(
            "BingKey", typeof (string), typeof (VerifyAddressUsingBingMapsActivity));

        public static DependencyProperty OutputCityProperty = DependencyProperty.Register(
            "OutputCity", typeof (string), typeof (VerifyAddressUsingBingMapsActivity));

        public static DependencyProperty OutputCountryProperty = DependencyProperty.Register(
            "OutputCountry", typeof (string), typeof (VerifyAddressUsingBingMapsActivity));

        public static DependencyProperty OutputLatitudeProperty = DependencyProperty.Register(
            "OutputLatitude", typeof (CrmFloat), typeof (VerifyAddressUsingBingMapsActivity));

        public static DependencyProperty OutputLine1Property = DependencyProperty.Register(
            "OutputLine1", typeof (string), typeof (VerifyAddressUsingBingMapsActivity));

        public static DependencyProperty OutputLongitudeProperty = DependencyProperty.Register(
            "OutputLongitude", typeof (CrmFloat), typeof (VerifyAddressUsingBingMapsActivity));

        public static DependencyProperty OutputMultipleFoundProperty = DependencyProperty.Register(
            "OutputMultipleFound", typeof (CrmBoolean), typeof (VerifyAddressUsingBingMapsActivity));

        public static DependencyProperty OutputPostalCodeProperty = DependencyProperty.Register(
            "OutputPostalCode", typeof (string), typeof (VerifyAddressUsingBingMapsActivity));

        public static DependencyProperty OutputStateProperty = DependencyProperty.Register(
            "OutputState", typeof (string), typeof (VerifyAddressUsingBingMapsActivity));

        [CrmInput("Address City")]
        public string AddressCity
        {
            get { return (string)GetValue(AddressCityProperty); }
            set { SetValue(AddressCityProperty, value); }
        }

        [CrmInput("Address Country")]
        public string AddressCountry
        {
            get { return (string)GetValue(AddressCountryProperty); }
            set { SetValue(AddressCountryProperty, value); }
        }

        [CrmInput("Address Line 1")]
        public string AddressLine1
        {
            get { return (string)GetValue(AddressLine1Property); }
            set { SetValue(AddressLine1Property, value); }
        }

        [CrmInput("Address Postal Code")]
        public string AddressPostalCode
        {
            get { return (string)GetValue(AddressPostalCodeProperty); }
            set { SetValue(AddressPostalCodeProperty, value); }
        }

        [CrmInput("Address State Or Province")]
        public string AddressState
        {
            get { return (string)GetValue(AddressStateProperty); }
            set { SetValue(AddressStateProperty, value); }
        }

        [CrmInput("Bing API Key")]
        public string BingKey
        {
            get { return (string)GetValue(BingKeyProperty); }
            set { SetValue(BingKeyProperty, value); }
        }

        [CrmOutput("City")]
        public string OutputCity
        {
            get { return (string)GetValue(OutputCityProperty); }
            set { SetValue(OutputCityProperty, value); }
        }

        [CrmOutput("Country Or Region")]
        public string OutputCountry
        {
            get { return (string)GetValue(OutputCountryProperty); }
            set { SetValue(OutputCountryProperty, value); }
        }

        [CrmOutput("Latitude")]
        public CrmFloat OutputLatitude
        {
            get { return (CrmFloat)GetValue(OutputLatitudeProperty); }
            set { SetValue(OutputLatitudeProperty, value); }
        }

        [CrmOutput("Line 1")]
        public string OutputLine1
        {
            get { return (string)GetValue(OutputLine1Property); }
            set { SetValue(OutputLine1Property, value); }
        }

        [CrmOutput("Longitude")]
        public CrmFloat OutputLongitude
        {
            get { return (CrmFloat)GetValue(OutputLongitudeProperty); }
            set { SetValue(OutputLongitudeProperty, value); }
        }

        [CrmOutput("Multiple Address Found")]
        public CrmBoolean OutputMultipleFound
        {
            get { return (CrmBoolean)GetValue(OutputMultipleFoundProperty); }
            set { SetValue(OutputMultipleFoundProperty, value); }
        }

        [CrmOutput("Postal Code")]
        public string OutputPostalCode
        {
            get { return (string)GetValue(OutputPostalCodeProperty); }
            set { SetValue(OutputPostalCodeProperty, value); }
        }

        [CrmOutput("State Or Province")]
        public string OutputState
        {
            get { return (string)GetValue(OutputStateProperty); }
            set { SetValue(OutputStateProperty, value); }
        }

        protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            // Reset Outputs
            OutputLatitude = new CrmFloat();
            OutputLongitude = new CrmFloat();
            OutputLine1 = String.Empty;
            OutputCity = String.Empty;
            OutputState = String.Empty;
            OutputPostalCode = String.Empty;
            OutputMultipleFound = new CrmBoolean {Value = false};

            var key = BingKey;
            if (String.IsNullOrEmpty(key) || key.ToLower() == "registry")
            {
                key = GetAPIKeyFromRegistry();
            }

            // Create Bing Maps Request
            var bingRequest = new GeocodeRequest
                              {
                                  Credentials = new Credentials {ApplicationId = key},
                                  Query = AddressLine1 + ", " +
                                          AddressCity + ", " +
                                          AddressState + ", " +
                                          AddressPostalCode + ", " +
                                          AddressCountry
                              };

            // Filter for High Confidence
            var filters = new ConfidenceFilter[1];
            filters[0] = new ConfidenceFilter {MinimumConfidence = Confidence.High};
            bingRequest.Options = new GeocodeOptions {Filters = filters};

            // Create Client
            GeocodeServiceClient bingClient = null;
            try
            {
                var geoBinding = new BasicHttpBinding(BasicHttpSecurityMode.None)
                                 {
                                     Name = "BasicHttpBinding_IGeocodeService",
                                     CloseTimeout = new TimeSpan(0, 1, 0),
                                     OpenTimeout = new TimeSpan(0, 1, 0),
                                     ReceiveTimeout = new TimeSpan(0, 10, 0),
                                     SendTimeout = new TimeSpan(0, 1, 0),
                                     AllowCookies = false,
                                     BypassProxyOnLocal = false,
                                     HostNameComparisonMode = HostNameComparisonMode.StrongWildcard,
                                     MaxBufferSize = 65536,
                                     MaxBufferPoolSize = 524288,
                                     MaxReceivedMessageSize = 65536,
                                     MessageEncoding = WSMessageEncoding.Text,
                                     TextEncoding = Encoding.UTF8,
                                     TransferMode = TransferMode.Buffered,
                                     UseDefaultWebProxy = true
                                 };

                var geoEA =
                    new EndpointAddress("http://dev.virtualearth.net/webservices/v1/geocodeservice/GeocodeService.svc");

                bingClient = new GeocodeServiceClient(geoBinding, geoEA);

                var bingResponse = bingClient.Geocode(bingRequest);

                if (bingResponse.Results != null &#038;&#038; bingResponse.Results.Length > 0)
                {
                    if (bingResponse.Results.Length > 1)
                    {
                        OutputMultipleFound.Value = true;
                    }

                    var bingResult = bingResponse.Results[0];

                    if (bingResult.Locations != null &#038;&#038; bingResult.Locations.Length > 0)
                    {
                        var bingLocation = bingResult.Locations[0];
                        OutputLatitude.Value = bingLocation.Latitude;
                        OutputLongitude.Value = bingLocation.Longitude;
                    }

                    var bingAddress = bingResult.Address;

                    OutputLine1 = bingAddress.AddressLine;
                    OutputPostalCode = bingAddress.PostalCode;
                    OutputCountry = bingAddress.CountryRegion;

                    OutputCity = String.IsNullOrEmpty(bingAddress.PostalTown)
                                     ? bingAddress.Locality
                                     : bingAddress.PostalTown;
                    OutputState = String.IsNullOrEmpty(bingAddress.AdminDistrict)
                                      ? bingAddress.District
                                      : bingAddress.AdminDistrict;
                }
            }
            catch (Exception ex)
            {
                throw new WorkflowTerminatedException(
                    "There was an error openning the connection to Bing Maps.", ex);
            }
            finally
            {
                // Close the client
                if (bingClient != null)
                {
                    bingClient.Close();
                }
            }

            return base.Execute(executionContext);
        }

        private static string GetAPIKeyFromRegistry()
        {
            // Opening the registry key
            var key = Registry.LocalMachine;
            if (key != null)
            {
                key = key.OpenSubKey("Software\\Microsoft Geocoder");
            }

            return key != null ? key.GetValue("APIKey").ToString() : null;
        }
    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://mscrmblogger.com/2010/05/20/geocode_with_bing/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Editing an Advanced Find Query in Excel</title>
		<link>http://mscrmblogger.com/2009/10/12/editing-an-advanced-find-query-in-excel/</link>
		<comments>http://mscrmblogger.com/2009/10/12/editing-an-advanced-find-query-in-excel/#comments</comments>
		<pubDate>Mon, 12 Oct 2009 11:28:44 +0000</pubDate>
		<dc:creator>Carlton Colter</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Integration]]></category>
		<category><![CDATA[advanced find]]></category>
		<category><![CDATA[crm]]></category>
		<category><![CDATA[crm 4]]></category>
		<category><![CDATA[crm4]]></category>
		<category><![CDATA[excel]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[microsoft dynamics CRM 4]]></category>

		<guid isPermaLink="false">http://mscrmblogger.com/?p=161</guid>
		<description><![CDATA[Here is a video tutorial of how to take a case advanced find, edit the query, troubleshoot errors in SQL Management Studio, and update your excel query.]]></description>
			<content:encoded><![CDATA[<p>Here is a video tutorial of how to take a case advanced find, edit the query, troubleshoot errors in SQL Management Studio, and update your excel query.</p>
<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/tr1FXu-tVHM&#038;hl=en&#038;fs=1&#038;ap=%2526fmt%3D22"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/tr1FXu-tVHM&#038;hl=en&#038;fs=1&#038;ap=%2526fmt%3D22" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></p>
<p>The steps are:</p>
<ol>
<li>Run an advanced find in CRM</li>
<li>Export it to Excel as a Dynamic Worksheet</li>
<li>Open it, save it as an excel file.</li>
<li>In Excel 2007, Click on Data in the ribbon, then Connections.</li>
<li>Click Properties</li>
<li>Click on Definition tab, edit the query</li>
<li>Click ok, then click close</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://mscrmblogger.com/2009/10/12/editing-an-advanced-find-query-in-excel/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

