locked
CRM 2013 - Plugin firing at the wrong time RRS feed

  • Question

  • Hi

    I have created a plugin for the entity Contacts, however when a lead is set to "Qualify" and create new account and contact is selected, my plugin is firing which is causing a error message to appear

    Within my plugin I did include the following

      if (entity.LogicalName == "contact")

    Which I believed would stop this from happening

    Does anyone have any suggestions / recommendations of action to take to prevent this, as switching my Contact plugin to only execute on Update isn't an option

    Thanks, Shaun


    S.Harrison

    Thursday, July 31, 2014 2:10 PM

All replies

  • Hi Shaun,

    If you do not want to execute the plugin code when contact is created by qualifying a lead then you can put below condition,

    Entity contact = context.InputParameters["Target"] as Entity;
                    if (context.MessageName.ToLower() == "create" && (contact.Attributes.Contains("originatinglead") || contact.Attributes["originatinglead"]!=null))
                    {
                        return;
                    }

    HTH!

    Friday, August 1, 2014 6:05 AM