<?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>Trace.WriteLine(_blogTitle); &#187; Plugins</title> <atom:link href="http://www.langalaxy.de/tag/plugins/feed/" rel="self" type="application/rss+xml" /><link>http://www.langalaxy.de</link> <description>Random output</description> <lastBuildDate>Fri, 28 Oct 2011 17:20:03 +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>Using HttpUtility.UrlEncode in a plugin leads to a SecurityException</title><link>http://www.langalaxy.de/2011/05/using-httputility-urlencode-in-a-plugin-leads-to-a-securityexception/</link> <comments>http://www.langalaxy.de/2011/05/using-httputility-urlencode-in-a-plugin-leads-to-a-securityexception/#comments</comments> <pubDate>Wed, 18 May 2011 21:28:18 +0000</pubDate> <dc:creator>ckeller</dc:creator> <category><![CDATA[Dynamics CRM]]></category> <category><![CDATA[.NET-4]]></category> <category><![CDATA[CRM 2011]]></category> <category><![CDATA[en]]></category> <category><![CDATA[Hints]]></category> <category><![CDATA[Plugins]]></category><guid
isPermaLink="false">http://www.langalaxy.de/?p=530</guid> <description><![CDATA[In a recent project I had to develop a plugin which is executed in the plugin sandbox. The sandbox restricts the rights plugins to a &#8216;safe&#8217; amount. See http://msdn.microsoft.com/en-us/library/gg334752.aspx for a description. According to the SDK, web request are allowed. Part of my task was to send a request to a web service which expects [...]]]></description> <content:encoded><![CDATA[<p>In a recent project I had to develop a plugin which is executed in the plugin sandbox. The sandbox restricts the rights plugins to a &#8216;safe&#8217; amount. See <a
href="http://msdn.microsoft.com/en-us/library/gg334752.aspx">http://msdn.microsoft.com/en-us/library/gg334752.aspx</a> for a description. According to the SDK, web request are allowed.</p><p>Part of my task was to send a request to a web service which expects data URL-encoded. Normally you would use following class (part of <code>System.Web</code>)</p><div
class="wp_syntax"><div
class="code"><pre class="csharp" style="font-family:monospace;">HttpUtility<span style="color: #008000;">.</span><span style="color: #0000FF;">UrlEncode</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;some data here&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></div></div><p>I was surprised that this leads to a <code>SecurityException</code> if used in a sand-boxed plugin. The sandbox does not allow the use of this class.</p><p>Instead of rewriting the method (I hate reinventing the wheel&#8230;) I&#8217;ve searched for a replacement, and found</p><div
class="wp_syntax"><div
class="code"><pre class="csharp" style="font-family:monospace;">Uri<span style="color: #008000;">.</span><span style="color: #0000FF;">EscapeDataString</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;some data here&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></div></div><p>which is usable in sand-boxed plugins. For my task the result was the same as with <code>UrlEncode</code>, however I am not sure I they are different in their results.</p> ]]></content:encoded> <wfw:commentRss>http://www.langalaxy.de/2011/05/using-httputility-urlencode-in-a-plugin-leads-to-a-securityexception/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Howto: Use pre-generated Guids for records</title><link>http://www.langalaxy.de/2010/06/howto-use-pre-generated-guids-for-records/</link> <comments>http://www.langalaxy.de/2010/06/howto-use-pre-generated-guids-for-records/#comments</comments> <pubDate>Sat, 05 Jun 2010 13:00:53 +0000</pubDate> <dc:creator>ckeller</dc:creator> <category><![CDATA[Dynamics CRM]]></category> <category><![CDATA[CRM 4]]></category> <category><![CDATA[HowTo]]></category> <category><![CDATA[Plugins]]></category><guid
isPermaLink="false">http://www.langalaxy.de/?p=433</guid> <description><![CDATA[A customer asked me recently if it is possible to get the id of a record in a pre-create plugin. By default, it is not possible because the record is not yet created at this point and has not got an id. However, Dynamics CRM allows you to create your own id for a record. [...]]]></description> <content:encoded><![CDATA[<p>A customer asked me recently if it is possible to get the id of a record in a pre-create plugin. By default, it is not possible because the record is not yet created at this point and has not got an id.</p><p>However, Dynamics CRM allows you to create your own id for a record. The primary key of a record is stored in its <a
href="http://msdn.microsoft.com/en-us/library/bb959605(v=MSDN.10).aspx">Key-Property</a>. On all default entities, for example account, the id property is marked as <em><strong>Valid for create</strong></em> (see <a
href="http://msdn.microsoft.com/en-us/library/cc151315(v=MSDN.10).aspx">accountid</a>). This means, the sdk allows you to pass your own id.</p><div
class="wp_syntax"><div
class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">Microsoft.Crm.Sdk</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">namespace</span> PreCreateKeyPlugin
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> PreCreateKeyPlugin <span style="color: #008000;">:</span> IPlugin
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> Execute<span style="color: #008000;">&#40;</span>IPluginExecutionContext context<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>IsPreCreate<span style="color: #008000;">&#40;</span>context<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>context<span style="color: #008000;">.</span><span style="color: #0000FF;">InputParameters</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Contains</span><span style="color: #008000;">&#40;</span>ParameterName<span style="color: #008000;">.</span><span style="color: #0000FF;">Target</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
                <span style="color: #008000;">&#123;</span>
                    DynamicEntity target <span style="color: #008000;">=</span> context<span style="color: #008000;">.</span><span style="color: #0000FF;">InputParameters</span><span style="color: #008000;">&#91;</span>ParameterName<span style="color: #008000;">.</span><span style="color: #0000FF;">Target</span><span style="color: #008000;">&#93;</span> <span style="color: #0600FF; font-weight: bold;">as</span> DynamicEntity<span style="color: #008000;">;</span>
&nbsp;
                    <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>target <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span>
                    <span style="color: #008000;">&#123;</span>
                        Guid customId <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Guid<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;{d7256b93-a5b5-45f9-9f2d-a1838279c35c}&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
                        target<span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;accountid&quot;</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Key<span style="color: #008000;">&#40;</span>customId<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                    <span style="color: #008000;">&#125;</span>
                <span style="color: #008000;">&#125;</span>
            <span style="color: #008000;">&#125;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">bool</span> IsPreCreate<span style="color: #008000;">&#40;</span>IPluginExecutionContext context<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span>  context<span style="color: #008000;">.</span><span style="color: #0000FF;">MessageName</span> <span style="color: #008000;">==</span> MessageName<span style="color: #008000;">.</span><span style="color: #0000FF;">Create</span> <span style="color: #008000;">&amp;&amp;</span> 
                    context<span style="color: #008000;">.</span><span style="color: #0000FF;">Stage</span> <span style="color: #008000;">==</span> MessageProcessingStage<span style="color: #008000;">.</span><span style="color: #0000FF;">BeforeMainOperationOutsideTransaction</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></div></div><p>If you register this plugin for pre-create on the account entity and create a new account, it will have the provided id.<br
/> <a
href="http://www.langalaxy.de/wp-content/uploads/2010/06/account.png"><img
src="http://www.langalaxy.de/wp-content/uploads/2010/06/account-300x74.png" alt="" title="Account" width="300" height="74" class="aligncenter size-medium wp-image-442" /></a></p><p>Please keep in mind, that you are in the responsibility to assign an new GUID for every execution of this plugin, but this should be clear when working with primary keys.</p> ]]></content:encoded> <wfw:commentRss>http://www.langalaxy.de/2010/06/howto-use-pre-generated-guids-for-records/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Who triggered my plugin?</title><link>http://www.langalaxy.de/2009/09/who-triggered-my-plugin/</link> <comments>http://www.langalaxy.de/2009/09/who-triggered-my-plugin/#comments</comments> <pubDate>Sat, 12 Sep 2009 18:40:58 +0000</pubDate> <dc:creator>ckeller</dc:creator> <category><![CDATA[Dynamics CRM]]></category> <category><![CDATA[CRM 4]]></category> <category><![CDATA[Hints]]></category> <category><![CDATA[Plugins]]></category> <category><![CDATA[SDK]]></category><guid
isPermaLink="false">http://www.langalaxy.de/?p=256</guid> <description><![CDATA[Do you ever want to know who triggered the execution of a plugin? This knowledge is handy, if you have to do some operation if the user entered data, but not if an external application made an update with the SDK. The IPluginExecutionContext contains the property CallerOrigin which will tell us more about the origin [...]]]></description> <content:encoded><![CDATA[<p>Do you ever want to know who triggered the execution of a plugin? This knowledge is handy, if you have to do some operation if the user entered data, but not if an external application made an update with the SDK.</p><p>The <em>IPluginExecutionContext</em> contains the property <a
href="http://msdn.microsoft.com/en-us/library/cc156395.aspx">CallerOrigin</a> which will tell us more about the origin which triggered the plugin execution.</p><p>The CallerOrigin is populated with one of these four types</p><ul><li><a
href="http://msdn.microsoft.com/en-us/library/cc156328.aspx">Application</a> &#8211; The user has triggered the event (by creating or editing a record).</li><li><a
href="http://msdn.microsoft.com/en-us/library/cc156329.aspx">AsyncService</a> &#8211; The async service triggered the event (by workflow execution).</li><li><a
href="http://msdn.microsoft.com/en-us/library/cc156336.aspx">WebServiceApi</a> &#8211; An application which makes use of the crm web service triggered the event.</li><li><a
href="http://msdn.microsoft.com/en-us/library/cc153425.aspx">OfflineOrigin</a> &#8211; The event was triggered by replaying offline actions while going online.</li></ul><p>This sample shows how to make use of this property (the sample is part of the sdk article <a
href="http://msdn.microsoft.com/en-us/library/cc151093.aspx">Online vs. Offline Plug-ins</a>)</p><div
class="wp_syntax"><div
class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">Microsoft.Crm.Sdk</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">Microsoft.Crm.SdkTypeProxy</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> OnlinePlugin <span style="color: #008000;">:</span> IPlugin
<span style="color: #008000;">&#123;</span>
   <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> Execute<span style="color: #008000;">&#40;</span>IPluginExecutionContext context<span style="color: #008000;">&#41;</span>
   <span style="color: #008000;">&#123;</span>
      <span style="color: #008080; font-style: italic;">// Check to see if this is a playback context.</span>
      CallerOrigin callerOrigin <span style="color: #008000;">=</span> context<span style="color: #008000;">.</span><span style="color: #0000FF;">CallerOrigin</span><span style="color: #008000;">;</span>
&nbsp;
      <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>callerOrigin <span style="color: #008000;">is</span> OfflineOrigin<span style="color: #008000;">&#41;</span>
      <span style="color: #008000;">&#123;</span>
         <span style="color: #008080; font-style: italic;">// This plug-in was fired from the playback queue after the user</span>
         <span style="color: #008080; font-style: italic;">// selected to go online within Microsoft Dynamics CRM for Outlook.</span>
         <span style="color: #0600FF; font-weight: bold;">return</span><span style="color: #008000;">;</span>
      <span style="color: #008000;">&#125;</span>
      <span style="color: #0600FF; font-weight: bold;">else</span>
      <span style="color: #008000;">&#123;</span>
         <span style="color: #008080; font-style: italic;">// Do something here.</span>
      <span style="color: #008000;">&#125;</span>
   <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>]]></content:encoded> <wfw:commentRss>http://www.langalaxy.de/2009/09/who-triggered-my-plugin/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Object Caching 339/339 objects using disk: basic

Served from: www.langalaxy.de @ 2012-02-07 02:55:25 -->
