1
votes

In CRM 2013, when a Lead is set as Qualified by the user, the lead is converted into a Opportunity. When this happens a record is also created in the entity Contact and Account. When a plugin is involved in the process it is necessary in the plugin to use the following code

 if (context.MessageName.ToLower() == "create" && entity.Attributes.Contains("originatingleadid") && entity["originatingleadid"] != null)
            {

                return;

            }
            else
            {
             //plugin code
            }

So that the plugin only executes when a contact / account is created and not when a lead is being converted to a opportunity

My question is how is this achievable when a Quote is being converted to a Order as when I am doing this process my plugin for Order is being activated and is throwing a business process error as 'the given key is not present in the dictionary'

1

1 Answers

2
votes

You should create a plugin which is registered to Pre/Post Operation of Order creation. Then, in your plugin in you should check for quoteid:

if (entity.Attributes.Contains("quoteid") && 
    entity["quoteid"] != null)
{
    return;
}
else
{
    //plugin code
}

Hope it helps!