CRM 2011 – How to check the context message in a plugin

A little tiddler of a blog post today but still a useful one.

I was writing a plugin for an entity and I wanted to use some of the same logic for a create message and for an update.

You will need to add two different steps but can still point these to the same plugin.  Then in the plugin you can check the context.MessageName to see what message has been passed into the plugin and then do different actions depending on the result.  I have sent the message to upper to take case out of the equation.

here is the code in an if statement

if (context.MessageName.ToUpper() == “CREATE”){


if (context.MessageName.ToUpper() == “UPDATE”) {


Leave a Reply

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 )

Google+ photo

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

Connecting to %s