Tag: IPluginExecutionContext

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. 

Read More »

Using MS CRM “IPluginExecutionContext” to Tackle Business Needs: A 3 Part Series

STOPPING A SALES ORDER FROM BEING CREATED

Stopping an operation using a plugin is a simple process. All you need to do is throw an exception, but its best to not just throw any exception. CRM provides the “InvalidPluginExectionException” that allows you to pass in a message that will get displayed to the user. Using that, we can alert the user that the action they took is not allowed and guide them in the direction of the correct way to create an order.

Read More »