PreEntity and PostEntity Images in CRM 4.0

Hi ,

When writing callouts for CRM 3.0, we were provided with PreEntityImageXml and PostEntityImageXml as a parameter to methds being overrided by us.

We could specify the fields for the same in the callout.config as prevalue and postvalue tag.

But the things have changed a bit in CRM 4.0.

Here we have to implement the Execute method found in the interface IPlugin.

public void Execute(IPluginExecutionContext context)

Here first we will register our assembly using Plugin Registration Tool

Than we will register a new step and specify the message against which we want to run our plugin.

After this comes the step where we will Register  new image.

In Register New Image dialog box

We can specify Pre Image and Post Image depending upon pre or post event. (Only for post event we can have both pre and post image)

Parameters -Here we can either specify certain fields or can select all attributes.

Entity Alias – Give a name to our image which we will refer in our code. (eg. say we gave LeadImage)

Now to access these values within our plugin we need  to do the following:-

Cast it into a DynamicEntity
DynamicEntity preLead = (DynamicEntity)context.PreEntityImages[“LeadImage”];
DynamicEntity postLead = (DynamicEntity)context.PostEntityImages[“LeadImage”];

For getting the id of the entity ( unlike crm 3.0 we don;t have entity context over here )

Key keyLeadId = (Key)postLead.Properties[“leadid”];
string leadId = keyLeadId.Value.ToString();

For lookup field use this line of code

Lookup lkpLobPre = (Lookup)preLead.Properties[“new_linesofbusinessid”];
strPreLobGuid = lkpLobPre.Value.ToString();
Lookup lkpLobPost = (Lookup)postLead.Properties[“new_linesofbusinessid”];
strPostLobGuid = lkpLobPost .Value.ToString();

For owner field

Owner ownerLead = (Owner)postLead.Properties[“ownerid”];
strPostOwnerGuid = ownerLead.Value.ToString();

For money field

CrmMoney estimatedvalue = (CrmMoney)postLead[“new_expectedrevenue”];
strExpectedRevenue = estimatedvalue.Value.ToString();

For string field

String geoName = (String)postLead[“new_geographyidname”];

For picklist field

Picklist leadqualitycode = (Picklist)postLead[“leadqualitycode”];
strRating =;


Author: Nishant Rana

I love working in and sharing everything about Microsoft.NET technology !

7 thoughts on “PreEntity and PostEntity Images in CRM 4.0”

  1. Thanks alot for your help 🙂
    Is there anyway to use images with status and status reason ?? If not so how to deal with them to monitor the values before and after the operations ??


Please share your thoughts

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

CRM for You and Me

Customer Relationship Mgt App for the Professional

D CRM Explorer

Learn about Microsoft Dynamics CRM Power Platform customization and implementation and other cool stuffs

Stroke // Jonas Rapp

I know pre-stroke. I will improve who I was.

Power Melange

Power Melange By Shalinee

Clavin's Blog

Power Automate - Power Apps - SharePoint Online - Azure - Nintex - K2 - Artificial Intelligence

Sat Sangha Salon

An Inquiry in Being

The Indoencers

The Influencers & Influences of Indian Music

Monika Halan's blog

Hand's-free money management

D365 Demystified

A closer look at Microsoft Dynamics 365.

Microsoft Mate (msftmate) - Andrew Rogers

Experienced consultant primarily focused on Microsoft Dynamics 365 and the Power Platform


Specific topics by Django Lohn on the whole Microsoft365 Stack

Manmit Rahevar's Blog

One Stop Destination for Microsoft Technology Solutions


Naturally Curious

Brian Illand

Power Platform and Dynamics 365

Steve Mordue MVP

A Microsoft Business Applications MVP

Subwoofer 101

Bass defines your home theater

SQLTwins by Nakul Vachhrajani

SQL Server tips and experiences dedicated to my twin daughters.

Everything D365

Discovering Azure DevOps and D365 Business Applications

Tech Wizard

Lets do IT Spells

Two Bite Tips

Valuable Tips To Grow Your Business

XRM Tricks (Power Platform & Dynamics CRM )

Power Platform & Dynamics CRM


Mail to for queries and suggestions

Giving back to the community what I have learned

xrm CRM Dynamics

Dynamics CRM Technical & Functional Info

Dynamics 365 Blogs - Explained in unique way

Sometimes you need to look at things from different perspective.

CRM Keeper

Dynamics 365 Customer Engagement, CRM, Microsoft CRM, Dynamics CRM


Step into the world of a Dynamics 365 Consultant

Dianamics PCF Lady

Diana & Dynamics 365 & Power Platform

Sara Lagerquist

No Code Customization Concepts


developer, designer, writer, fun loving, patriotic, humble and a sweet person inside out :) love and respect people who have a great sense of humor.

Temmy Wahyu Raharjo

Dreaming to be a clean coder and TDD minded programmer.

Transform 365

We blog about problems we face and code we write to help others

%d bloggers like this: