<?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>iCRM Blog &#187; C#</title>
	<atom:link href="http://blog.icrm.ca/tag/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.icrm.ca</link>
	<description>xRM fits in so many ways</description>
	<lastBuildDate>Thu, 25 Feb 2010 23:07:07 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Retrieving Pre and Post data in MSCRM Plug-ins (Create, Update and Delete)</title>
		<link>http://blog.icrm.ca/2010/01/12/retrieving-pre-and-post-data-in-mscrm-plug-ins-create-update-and-delete/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://blog.icrm.ca/2010/01/12/retrieving-pre-and-post-data-in-mscrm-plug-ins-create-update-and-delete/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 22:12:30 +0000</pubDate>
		<dc:creator>Colin</dc:creator>
				<category><![CDATA[Dynamics CRM]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[mscrm]]></category>
		<category><![CDATA[plug-ins]]></category>

		<guid isPermaLink="false">http://blog.icrm.ca/2010/01/12/retrieving-pre-and-post-data-in-mscrm-plug-ins-create-update-and-delete/</guid>
		<description><![CDATA[







 
When you look at the sample of plug-in in the SDK they all use the InputParameters property bag. The InputParameters property bag contains all the information specified in the Request class whose message caused the plug-in to execute. As the request class does not include the pre and post data of the entity, the InputParameters [...]]]></description>
			<content:encoded><![CDATA[<!--CusAds1--><p> </p>
<p>When you look at the sample of plug-in in the SDK they all use the InputParameters property bag. The InputParameters property bag contains all the information specified in the Request class whose message caused the plug-in to execute. As the request class does not include the pre and post data of the entity, the InputParameters property does not contain the pre and post data. The InputParameters property does contain a &#8220;Target&#8221; property which is a Dynamic Entity of the data that was changed in your entity. Note: The target Dynamic Entity only has the properties (fields) that where changed.</p>
<p>To get the pre and post date of an Entity in a plug-in you need to use the context.PreEntityImages and context.PostEntityImages property bags. You will also need to add an image. In the image you give it an alias and indicate if it is pre and/or post and also define what attributes (fields) you need.</p>
<p><img src="http://blog.icrm.ca/wp-content/uploads/2010/01/011210_2212_RetrievingP1.png" alt="" /></p>
<p>If you don&#8217;t know or the fields could change leave the attributes as all fields. If you only need a few fields everything should run faster if you just indicate the fields you need. Now to get a pre DynamicEntity in your plug-in you use context.PreEntityImages.Properties["image alias"]. Note in the following code I first check that the PreEntityImages.Properties contains the &#8220;image alias&#8221; and the the property is a DynamicEntity.</p>
<p> </p>
<p style="margin-left: 36pt"><span style="font-family:Courier New; font-size:10pt"><span style="color:#2b91af">DynamicEntity</span> preSaveEntity;<br />
</span></p>
<p style="margin-left: 36pt"><span style="font-family:Courier New; font-size:10pt"><span style="color:#2b91af">DynamicEntity</span> postSaveEntity;<span style="color:blue"><br />
</span></span></p>
<p style="margin-left: 36pt"><span style="font-family:Courier New; font-size:10pt"><span style="color:blue">if</span> (context.PreEntityImages.Properties.Contains(<span style="color:#a31515">&#8220;icrmAddress&#8221;</span>) &amp;&amp; context.PreEntityImages.Properties[<span style="color:#a31515">"icrmAddress"</span>] <span style="color:blue">is</span><br />
<span style="color:#2b91af">DynamicEntity</span>)<br />
</span></p>
<p><span style="font-family:Courier New; font-size:10pt">{<br />
</span></p>
<p><span style="font-family:Courier New; font-size:10pt">preSaveEntity = (<span style="color:#2b91af">DynamicEntity</span>)context.PreEntityImages.Properties[<span style="color:#a31515">"icrmAddress"</span>];<br />
</span></p>
<p><span style="font-family:Courier New; font-size:10pt">}<br />
</span></p>
<p><span style="font-family:Courier New; font-size:10pt"><br />
<span style="color:blue">if</span> (context.PostEntityImages.Properties.Contains(<span style="color:#a31515">&#8220;icrmAddress&#8221;</span>) &amp;&amp; context.PostEntityImages.Properties[<span style="color:#a31515">"icrmAddress"</span>] <span style="color:blue">is</span><br />
<span style="color:#2b91af">DynamicEntity</span>)<br />
</span></p>
<p><span style="font-family:Courier New; font-size:10pt">{<br />
</span></p>
<p><span style="font-family:Courier New; font-size:10pt">postSaveEntity = (<span style="color:#2b91af">DynamicEntity</span>)context.PostEntityImages.Properties[<span style="color:#a31515">"icrmAddress"</span>];<br />
</span></p>
<p><span style="font-family:Courier New; font-size:10pt">}</span></p>
<p> </p>
<p>You are not always going to have a pre and post data it will depend on the Message(Create, Update, Delete, etc) and the Eventing Pipeline Stage of Execution (Pre Stage or Post Stage).</p>
<p>Need a custom MSCRM Plug-in created contact iCRM at <a href="http://www.icrm.ca">http://www.icrm.ca</a> or through<a href="http://www.linkedin.com/in/colinfreeland"><img src="cid:image003.gif@01CA9374.E32395D0" border="0" alt="" /></a>.</p>
<p>I used <a href="http://code.msdn.microsoft.com/crmplugin">CRM Plugin Registration Tool 2.2</a></p>

<div style="font-size:0px;height:0px;line-height:0px;margin:0;padding:0;clear:both"></div><div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-bg-enjoy"><ul class="socials"><li class="sexy-twitter"><a href="http://twitter.com/home?status=Retrieving+Pre+and+Post+data+in+MSCRM+Plug-ins+%28Create%2C+Update+and+Delete%29+-+http://tinyurl.com/ykowxm3+" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a></li><li class="sexy-mail"><a href="mailto:?subject=%22Retrieving%20Pre%20and%20Post%20data%20in%20MSCRM%20Plug-ins%20%28Create%2C%20Update%20and%20Delete%29%22&amp;body=I%20thought%20this%20article%20might%20interest%20you.%0A%0A%22%C2%A0%0D%0A%0D%0AWhen%20you%20look%20at%20the%20sample%20of%20plug-in%20in%20the%20SDK%20they%20all%20use%20the%20InputParameters%20property%20bag.%20The%20InputParameters%20property%20bag%20contains%20all%20the%20information%20specified%20in%20the%20Request%20class%20whose%20message%20caused%20the%20plug-in%20to%20execute.%20As%20the%20request%20class%20does%20not%20include%20the%20pre%20and%20post%20data%22%0A%0AYou%20can%20read%20the%20full%20article%20here%3A%20http://blog.icrm.ca/2010/01/12/retrieving-pre-and-post-data-in-mscrm-plug-ins-create-update-and-delete/" rel="nofollow" class="external" title="Email this to a friend?">Email this to a friend?</a></li><li class="sexy-delicious"><a href="http://del.icio.us/post?url=http://blog.icrm.ca/2010/01/12/retrieving-pre-and-post-data-in-mscrm-plug-ins-create-update-and-delete/&amp;title=Retrieving+Pre+and+Post+data+in+MSCRM+Plug-ins+%28Create%2C+Update+and+Delete%29" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a></li><li class="sexy-digg"><a href="http://digg.com/submit?phase=2&amp;url=http://blog.icrm.ca/2010/01/12/retrieving-pre-and-post-data-in-mscrm-plug-ins-create-update-and-delete/&amp;title=Retrieving+Pre+and+Post+data+in+MSCRM+Plug-ins+%28Create%2C+Update+and+Delete%29" rel="nofollow" class="external" title="Digg this!">Digg this!</a></li><li class="sexy-stumbleupon"><a href="http://www.stumbleupon.com/submit?url=http://blog.icrm.ca/2010/01/12/retrieving-pre-and-post-data-in-mscrm-plug-ins-create-update-and-delete/&amp;title=Retrieving+Pre+and+Post+data+in+MSCRM+Plug-ins+%28Create%2C+Update+and+Delete%29" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a></li><li class="sexy-technorati"><a href="http://technorati.com/faves?add=http://blog.icrm.ca/2010/01/12/retrieving-pre-and-post-data-in-mscrm-plug-ins-create-update-and-delete/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a></li><li class="sexy-comfeed"><a href="http://blog.icrm.ca/2010/01/12/retrieving-pre-and-post-data-in-mscrm-plug-ins-create-update-and-delete/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a></li><li class="sexy-linkedin"><a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://blog.icrm.ca/2010/01/12/retrieving-pre-and-post-data-in-mscrm-plug-ins-create-update-and-delete/&amp;title=Retrieving+Pre+and+Post+data+in+MSCRM+Plug-ins+%28Create%2C+Update+and+Delete%29&amp;summary=%C2%A0%0D%0A%0D%0AWhen%20you%20look%20at%20the%20sample%20of%20plug-in%20in%20the%20SDK%20they%20all%20use%20the%20InputParameters%20property%20bag.%20The%20InputParameters%20property%20bag%20contains%20all%20the%20information%20specified%20in%20the%20Request%20class%20whose%20message%20caused%20the%20plug-in%20to%20execute.%20As%20the%20request%20class%20does%20not%20include%20the%20pre%20and%20post%20data&amp;source=iCRM Blog" rel="nofollow" class="external" title="Share this on Linkedin">Share this on Linkedin</a></li><li class="sexy-printfriendly"><a href="http://www.printfriendly.com/print?url=http://blog.icrm.ca/2010/01/12/retrieving-pre-and-post-data-in-mscrm-plug-ins-create-update-and-delete/" rel="nofollow" class="external" title="Send this page to Print Friendly">Send this page to Print Friendly</a></li></ul><div style="clear:both;"></div></div>]]></content:encoded>
			<wfw:commentRss>http://blog.icrm.ca/2010/01/12/retrieving-pre-and-post-data-in-mscrm-plug-ins-create-update-and-delete/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

