Using MS CRM “IPluginExecutionContext” to Tackle Business Needs: A 3 Part Series
The “IPluginExecutionContext” contains a property called “MessageName.” This is the name of the message that was called to perform the action. Here is a link to a list of messages: https://msdn.microsoft.com/en-us/library/gg309482.aspx . I couldn’t find my original source for this, so you can assume that each message name is just the class name listed without the request at the end. The one we are interested in is the “ConvertQuotetoSalesOrderRequest” or the “ConvertQuoteToSalesOrder” message. This is what is called when you click the “Create Order” button and can be called through the API as well. So to figure out if that is what is creating our sales order we would simply need to traverse the parent context list and check to see if the “MessageName” property equals “ConvertQuoteToSalesOrder”. Here is a code snippet to do that.