<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>rsquare</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/rsquare/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/rsquare/feed.xml</link>
    <description />
    <lastBuildDate>Wed, 17 Apr 2019 03:51:49 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>How are optionsets stored in CRM 2011 DB</title>
      <link>https://docs.microsoft.com/archive/blogs/rsquare/how-are-optionsets-stored-in-crm-2011-db</link>
      <pubDate>Tue, 31 Jan 2012 23:03:05 GMT</pubDate>
      <dc:creator><![CDATA[Rahul_Ranjit]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/rsquare/2012/01/31/how-are-optionsets-stored-in-crm-2011-db/</guid>
      <description><![CDATA[I ran into a question while working on a project on how Option sets were stored in CRM 2011. I...]]></description>
      <content:encoded><![CDATA[<p>I ran into a question while working on a project on how Option sets were stored in CRM 2011. I started looking into the DB and it looks pretty straight forward. Any option sets including the Global and non Global(I guess you could call them that) are stored in three tables:</p>
<p>1. OptionSetIds - This table contains just a column which contains a unique identifier for each new OptionSet that you create.</p>
<p>2. MetadataSchema.AttributePicklistValue - OptionSet Values are primarily indicated by the value stored in this table. It is stored in the Value column in this table.</p>
<p>3. MetadataSchema.LocalizedLabel - This is where the Option Set Label Value is stored. Just matchup the AtributePicklistValueId in MetadataSchema.AttributePicklistValue against the ObjectId in MetadataSchema.LocalizedLabel/</p>
<p>&nbsp;</p>
<p>This breakup allows for localization of the OptionSet Labels........</p>]]></content:encoded>
    </item>
    <item>
      <title>Updating records using Data Import</title>
      <link>https://docs.microsoft.com/archive/blogs/rsquare/updating-records-using-data-import</link>
      <pubDate>Sun, 29 Jan 2012 16:43:16 GMT</pubDate>
      <dc:creator><![CDATA[Rahul_Ranjit]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/rsquare/2012/01/29/updating-records-using-data-import/</guid>
      <description><![CDATA[I was trying to update a few records after exporting them out of CRM 2011. To do that:
* Create an...]]></description>
      <content:encoded><![CDATA[<p>I was trying to update a few records after exporting them out of CRM 2011. To do that:</p>
<p>* Create an Advanced Find view will all the columns that you would like to update (saves the pain of sifting through information.)</p>
<p>* Export to excel with "MAKE THIS DATA AVAILABLE FOR REIMPORTING BY INCLUDING REQUIRED COLUMN HEADERS" checked....</p>
<p>* Save the excel and update the data.</p>
<p>* Reimport the data back.</p>
<p>&nbsp;</p>
<p>At this point I saw that imported file was added in the "Imports" with status as "Submitted". This status did not change for quite some time. Considering the fact that this was my VPC I expected it to be parsed and transformed immediately.</p>
<p>The problem was that the CRM Asynch service was not running and hence the undue delay....</p>
<p>&nbsp;</p>]]></content:encoded>
    </item>
    <item>
      <title>Sharepoint Connector for CRM 2011 - GRIEF</title>
      <link>https://docs.microsoft.com/archive/blogs/rsquare/sharepoint-connector-for-crm-2011-grief</link>
      <pubDate>Mon, 23 Jan 2012 02:05:00 GMT</pubDate>
      <dc:creator><![CDATA[Rahul_Ranjit]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/rsquare/2012/01/23/sharepoint-connector-for-crm-2011-grief/</guid>
      <description><![CDATA[&nbsp;Im working on the Sharepoint connector and Im running into some issues...Ill keep a record on...]]></description>
      <content:encoded><![CDATA[<p><span style="font-family: Calibri; font-size: small;" size="3" face="Calibri">&nbsp;Im working on the Sharepoint connector and Im running into some issues...Ill keep a record on this blog....</span></p>
<p><span style="font-size: small;" size="3"><span style="font-family: Calibri;" face="Calibri">I installed the SharePoint connector for CRM 2011 and observed that the Sharepoint libraries which were getting created based on the account name(lets assume that I have registered the Sharepoint Integration for Accounts). Now I go ahead and create another account with the same name. Unless I manually update the relative url it drops the documents into the same library as the one I created before.</span></span></p>
<p><span style="font-family: Calibri;" face="Calibri"><span style="font-size: small;" size="3">For ex:</span></span></p>
<ul>
<li><span style="font-size: small;" size="3">&middot;</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="font-size: small;" size="3"><span style="font-family: Calibri;" face="Calibri">I create an account with the name &ldquo;Test&rdquo;</span></span></li>
<li><span style="font-size: small;" size="3">&middot;</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="font-size: small;" size="3"><span style="font-family: Calibri;" face="Calibri">I go to documents and upload a document doc1.xlsx</span></span></li>
<li><span style="font-size: small;" size="3">&middot;</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="font-size: small;" size="3"><span style="font-family: Calibri;" face="Calibri">I create another account with the name &ldquo;Test&rdquo;</span></span></li>
<li><span style="font-size: small;" size="3">&middot;</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="font-size: small;" size="3"><span style="font-family: Calibri;" face="Calibri">I go the documents and upload a document called doc2.xlsx</span></span></li>
</ul>
<p><span style="font-family: Calibri; font-size: small;" size="3" face="Calibri">&nbsp;</span></p>
<p><span style="font-size: small;" size="3"><span style="font-family: Calibri;" face="Calibri">Now I can see both the documents on the document tabs in both doc1 and doc2.</span></span></p>
<p><span style="font-family: Calibri; font-size: small;" size="3" face="Calibri">&nbsp;</span></p>
<p><span style="font-size: small;" size="3"><span style="font-family: Calibri;" face="Calibri">I tried to fix this problem by writing a pre create plugin to update the relative url with the accounts guid. I thought CRM would create the document library after the entity was created&hellip;..and boy was I wrong&hellip;.CRM goes ahead and creates the Sharepoint library irrespective of the data contained in the Sharepoint Document Location Entity. </span></span></p>
<p><span style="font-family: Calibri; font-size: small;" size="3" face="Calibri">&nbsp;</span></p>]]></content:encoded>
    </item>
    <item>
      <title>HttpStageProcessingException using WCF Rest Services</title>
      <link>https://docs.microsoft.com/archive/blogs/rsquare/httpstageprocessingexception-using-wcf-rest-services</link>
      <pubDate>Sun, 11 Dec 2011 02:10:38 GMT</pubDate>
      <dc:creator><![CDATA[Rahul_Ranjit]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/rsquare/2011/12/11/httpstageprocessingexception-using-wcf-rest-services/</guid>
      <description><![CDATA[I was fiddling around with REST services and came up on an interesting error. Whenever I set a...]]></description>
      <content:encoded><![CDATA[<p>I was fiddling around with REST services and came up on an interesting error. Whenever I set a Response Format on the Web Invoke attribute I would get a HttpStageProcessing error. No issues with XML format but when JSON serialization was setup it would throw this error.......A couple of hours later and atleast half a dozen unsuccessful fixes later, I found out the issue: If you dont set a DateTime property on the data contract&nbsp;&nbsp;to an explicit value you get this issue.....I tried manually setting it to the two extremeities DateTime.MinValue does not serialize successfully whereas DateTime.maxValue does.&nbsp;</p>
<p>&nbsp;</p>
<p>If you are stuck with this error this post could possibly save you an hour or so.</p>]]></content:encoded>
    </item>
    <item>
      <title>CRM Licensing - Good Reads</title>
      <link>https://docs.microsoft.com/archive/blogs/rsquare/crm-licensing-good-reads</link>
      <pubDate>Mon, 17 Oct 2011 01:54:00 GMT</pubDate>
      <dc:creator><![CDATA[Rahul_Ranjit]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/rsquare/2011/10/17/crm-licensing-good-reads/</guid>
      <description><![CDATA[https://thinkcrm.wordpress.com/2011/03/26/changes-to-crm-2011-on-premise-licensing-model/
&nbsp;]]></description>
      <content:encoded><![CDATA[<p><a href="https://thinkcrm.wordpress.com/2011/03/26/changes-to-crm-2011-on-premise-licensing-model/">https://thinkcrm.wordpress.com/2011/03/26/changes-to-crm-2011-on-premise-licensing-model/</a></p>
<p>&nbsp;</p>]]></content:encoded>
    </item>
    <item>
      <title>Hello MSDN - Uploading Contact Images in CRM 2011</title>
      <link>https://docs.microsoft.com/archive/blogs/rsquare/hello-msdn-uploading-contact-images-in-crm-2011</link>
      <pubDate>Sat, 15 Oct 2011 07:46:00 GMT</pubDate>
      <dc:creator><![CDATA[Rahul_Ranjit]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/rsquare/2011/10/15/hello-msdn-uploading-contact-images-in-crm-2011/</guid>
      <description><![CDATA[I am not a blogger, however I found that jotting things down at a central location helps you refer...]]></description>
      <content:encoded><![CDATA[<p>I am not a blogger, however I found that jotting things down at a central location helps you refer back.....I am going to use this blog to note things down which annoyed me at work.......and no I wont be pointing fingers at anyone here...... :) <strong><span style="text-decoration: underline;">And yes the code I post here are proof of concept snippets....please dont use them without the due deligence</span></strong></p>
<p>One of my clients requirements included adding a photograp of a contact in a Contact Entity. Surprisingly this is not supported out of the box in CRM 2011. So I decided to write a small Silverlight component to proof out my design approach.</p>
<p>Files can be attached to entities in CRM and the contact entity definitely allows you to attach files to it. I thought this should be a good way to get started.</p>
<p>1. Retrieve/Store the file in the contacts' attahcement</p>
<p>2. Create a silverlight component which will allow the user to upload/retrieve the image.</p>
<p>3. Customize the contact form to add the silverlight web resource</p>
<p>4. And we are done......</p>
<p>&nbsp;</p>
<p>The silverlight part was a breeze when it came to retrieving and displaying a contact's picture which I manually loaded. The code for that is as follows:</p>
<p>1. Create your silverlight control and add reference to the csdl file.</p>
<p>2. Ad an image control to your silverlight control and use this piece of code to fetch the image</p>
<pre class="scroll"><code class="csharp"><span style="background-color: #ffff00;"> Annotation annotation = new Annotation(); </span><br /><span style="background-color: #ffff00;"> var data = page.GetProperty("data") as ScriptObject; </span><br /><span style="background-color: #ffff00;"> var entity = data.GetProperty("entity") as ScriptObject; </span><br /> <br /><span style="background-color: #ffff00;"> if(Guid.TryParse(entity.Invoke("getId",null).ToString(),out recordId)) </span><br /><span style="background-color: #ffff00;"> { </span><br /><span style="background-color: #ffff00;"> DataServiceQuery&lt;Annotation&gt; query = (DataServiceQuery&lt;Annotation&gt;)(context.AnnotationSet.Where&lt;Annotation&gt; </span><br /><span style="background-color: #ffff00;"> (note =&gt; note.ObjectId != null &amp;&amp; note.ObjectTypeCode=="contact" &amp;&amp; note.FileName=="contactpicture.jpg" )); </span><br /><span style="background-color: #ffff00;"> query.BeginExecute(NoteFetchCallback, query); </span><br /> <br /> }</code></pre>
<p>And the call back looks like:</p>
<pre class="scroll"><code class="csharp"> private void NoteFetchCallback(IAsyncResult result) <br /> { <br /> var query = result.AsyncState as DataServiceQuery&lt;Annotation&gt;; <br /> <br /> if (query != null) <br /> { <br /> var results = query.EndExecute(result).ToList(); <br /> if (results.Count &gt; 0) <br /> { <br /> var contactPicture = results[0]; <br /> imageArray = Convert.FromBase64String(contactPicture.DocumentBody); <br /> MemoryStream stream = new MemoryStream(imageArray); <br /> BitmapImage image = new BitmapImage(); <br /> image.SetSource(stream); <br /> imageContact.Source = image; <br /> } <br /> <br /></code></pre>
<p>3. I moved on with the upload functionality as well:</p>
<pre class="scroll"><code class="csharp"> OpenFileDialog dialog = new OpenFileDialog() { Multiselect = false, Filter = ".jpg|" }; <br /> dialog.ShowDialog(); <br /> var fileInfo = dialog.File; <br /> imageArray = new byte[fileInfo.Length]; <br /> var fileStream = fileInfo.OpenRead(); <br /> fileStream.Read(imageArray, 0, (int)fileInfo.Length - 1); <br /> <br /> <br /> Annotation annotation = new Annotation() { MimeType = @"image/pjpeg", FileName = "contactpicture.jpg", DocumentBody = Convert.ToBase64String(imageArray), ObjectId = new EntityReference() { Id=recordId, LogicalName="contact" } }; <br /> context.AddToAnnotationSet(annotation); <br /> context.BeginSaveChanges(null, null); <br /> </code></pre>
<p>However I noticed that the images I would upload this way would fail in the fetch and display operation in Silverlight. and it would give me a weird error <span style="font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;"><span style="background-color: #ffff00;"><em>Error HRESULT E_FAIL</em></span><br /><span style="background-color: #ffff00;"><em>has been returned from a call to a COM component.</em></span> at the line highlighted in red : </span></p>
<pre class="scroll"><span style="font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;">private void NoteFetchCallback(IAsyncResult result) <br /> { <br /> var query = result.AsyncState as DataServiceQuery&lt;Annotation&gt;; <br /> <br /> if (query != null) <br /> { <br /> var results = query.EndExecute(result).ToList(); <br /> if (results.Count &gt; 0) <br /> { <br /> var contactPicture = results[0]; <br /> imageArray = Convert.FromBase64String(contactPicture.DocumentBody); <br /> MemoryStream stream = new MemoryStream(imageArray); <br /> BitmapImage image = new BitmapImage(); <br /> <span style="background-color: #ff6600;">image.SetSource(stream);</span> <br /> imageContact.Source = image; <br /> } <br /></span></pre>
<pre class="scroll"><span style="font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;"></span>&nbsp;</pre>
<p><span style="font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;">After digging around a bit I found that there was a silverlight component which does the same thing uploaded in Codeplex: <a href="https://crmattachmentimage.codeplex.com/">https://crmattachmentimage.codeplex.com/</a></span></p>
<p><span style="font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;">I looked around at the source code and Carlton had commented that the array into which you load the image should have two more extra bytes of memmory which will be used by the BitmapImage.SetSource method to add temination characters.</span></p>
<p><span style="font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;">I added the fix and things started working again...... This is the upload snippet which works:</span></p>
<pre class="scroll"><span style="font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;"></span></pre>
<pre class="scroll"><code class="csharp"> OpenFileDialog dialog = new OpenFileDialog() { Multiselect = false, Filter = ".jpg|" }; <br /> dialog.ShowDialog(); <br /> var fileInfo = dialog.File; <br /> <span style="background-color: #00ff00;">imageArray = new byte[fileInfo.Length+2];</span> <br /> var fileStream = fileInfo.OpenRead(); <br /> fileStream.Read(imageArray, 0, (int)fileInfo.Length - 1); <br /> <br /> <br /> Annotation annotation = new Annotation() { MimeType = @"image/pjpeg", FileName = "contactpicture.jpg", DocumentBody = Convert.ToBase64String(imageArray), ObjectId = new EntityReference() { Id=recordId, LogicalName="contact" } }; <br /> context.AddToAnnotationSet(annotation); <br /> context.BeginSaveChanges(null, null);</code><span style="font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;"></span></pre>
<pre class="scroll"><span style="text-decoration: underline;"><strong><span style="font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;"></span></strong></span></pre>
<p><span style="text-decoration: underline;"><strong> It never occured to me to check codeplex before I started writing this component - Lesson Learnt!</strong></span> and yes the image thingy too.....</p>
<p>&nbsp;I did take a look at the code in codeplex and I felt it could do with some changes. Particularly around</p>
<p>1. Using a Provider model so that we can switch the data store easily. For example if I need to upload the image to a sharepoint site or maybe even a folder in the server I have to pretty much rewrite the whole control.</p>
<p>2. I also noticed that the solution adds another hidden field to maintain the link between a contact and the Annotation entity which contains the file. I dont think this is a good approach. I strongly feel that the image should be stored along with the entities attachment. The approach of using attachments will work only for entities to which attachments and its security permissions&nbsp;are allowed. However this problem can be easily addressed if there is a Provider model in picture.</p>
<p>Man...writing blogs are tiring...... :(</p>
<p>&nbsp;</p>]]></content:encoded>
    </item>
  </channel>
</rss>