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 = leadqualitycode.name;

Bye

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 ??

    Like

Please share your thoughts

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

Power Spark

Power Spark By Shrangarika

Van Carl Nguyen

Exploration of Power Platform

My Trial

It is my experience timeline.

Power⚡Thomas

Sharing my knowledge and experience about the Microsoft Power Platform.

Arpit Power Guide

a guide to powering up community

Welcome to the Blog of Paul Andrew

Sponsored by Cloud Formations Ltd

Deriving Dynamics 365

Deriving Solutions and features on Power Platform/Dynamics 365

The CRM Ninja

Thoughts & musings from a Dynamics 365 Ninja!

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

Knowhere365

Specific topics by Django Lohn on the whole Microsoft365 Stack

Manmit Rahevar's Blog

One Stop Destination for Microsoft Technology Solutions

MG

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

XRM Tricks (Power Platform & Dynamics CRM )

Power Platform & Dynamics CRM

CRM TIPS BY PRM

Mail to crmtipsbyprm@gmail.com for queries and suggestions

nijos.dev

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