Skip to main content

Posts

Showing posts from April, 2009

Simple code to pull CRM info from PreImageEntity

This is simple code that I used in the process of a larger project that I am performing with CRM and SharePoint. I am used to using the dynamic entity class to pull any info I need in the post stage of a plug-in for use in my code. I was getting an issue where the plug-in would fire on an update method and it would kick back an error "The given key was not present in the dictionary". This is from the way I was trying to pull the attributes. Not being familiar with C#, it took me a while to find a solution for this. Browsing the web and the CrmSdk, I came across a method I could use, PreImageEntity and PostImageEntity, with the CRM Plug-In Registration tool. Code: public void Execute(IPluginExecutionContext context) { //Grab the account name from a preimage named "AccountEntity" DynamicEntity AccountEntity = (DynamicEntity)context.PreEntityImages["AccountEntity"];   //PreEntity passes values as an object so, force accountName variable as a strin