Urgent : How to Fire PlugIn on change of only 1 Attribute RRS feed

  • Question

  • Dear Sir,

    Can a PlugIn be Fired on Chnage of only 1 Attribute like Email Address for Contact. If Yes, then how to configure? Whats steps needs to be done. Also, plz provide some examples if avaliable.

    Thanks - Abbas

    Wednesday, May 4, 2011 7:11 AM


All replies

  • Abbas,

    when u register a plugin using PluginRegistration tool.

    you folloe these steps:

    1. register your assembly.

    2. Add step to your assembly  "Step is representing a response to an Action happened on CRM Entity"

    while registring the step use the filtering attribute " Email Address " only

    and you are done.

     Know more about plugin registration : http://www.knowledgeexchanger.com/ms-crm-tips/how-to-register-a-plugin-inside-ms-crm-4-0-using-registration-tool-shipped-with-crm-sdk-4-0-plugins-on/


    vishal swami

    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"


    Wednesday, May 4, 2011 7:29 AM
  • are you wonding how to get it to fire on the save or in the onchange event?
    Jamie Miley
    Linked-In Profile
    Follow Me on Twitter!
    Wednesday, May 4, 2011 2:02 PM
  • Plugin and Workflow fires when you change a field and click save button where as javascript fires without clicking save button. For plugin you have to write code and register the dll file. During registration you specify when it should be fired. Update event is available in workflows and you don't need to write code. If you can tell your requirement in more details like what do you want to do on change of email address than we can suggested a solution for that. 
    Regards Faisal
    Wednesday, May 4, 2011 2:13 PM
  • Hi

    First thing you can check for a single attribute change using a plugin but it will always fire when you save a record (PRE / POST  Create or Update) whether you change one attribute or many.

    Step 1: You will have to register a pre create and a pre update plugins on the enity where you intend to perform any validatiions and reject the input.


    If your are just updating an external database or website then you can trigger POST CREATE or POST UPDATE events and take the inteneded action.


    STEP 2: Where you intend to raise an error you thow plugin exception as follows

      throw new InvalidPluginExecutionException("Invalid Email Address");



    Here is a simple plugin example to validate and accountnumber....


    using System;
    using Microsoft.Crm.Sdk;
    using System.Text.RegularExpressions;
    namespace ProgrammingWithDynamicsCrm4.Plugins
     public class AccountNumberValidator: IPlugin
      public void Execute(IPluginExecutionContext context)
       DynamicEntity target =
       if (target.Properties.Contains("accountnumber"))
        string accountNumber = (string)target["accountnumber"];
        Regex validFormat = new Regex("[A-Z]{2}-[0-9]{6}");
        if (!validFormat.IsMatch(accountNumber))
         string message =
          "Account number does not follow the required format. " +
         throw new InvalidPluginExecutionException(message);


    Hope this helps. Amar

    CRM Forum Guidance on how to Help Us Help You

    Wednesday, May 4, 2011 4:49 PM