web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :

Contracts, Renewals, and Plugins

Mitch Milam Profile Picture Mitch Milam

I ran into an interesting issue today during a CRM 4.0 upgrade to 2011.

We have a plugin that automatically generates a Contract Detail record when a Contract is created. This is because Contracts need at least one detail record but the customer is not using the actual details.

The issue arose when the Contract was renewed. The Contract Detail creation plugin was fired and it threw an error because it didn't like something about the Contract Detail record it was creating.

I investigated the Renewal Process and found that we should not be firing the Contract Detail creation plugin during this process because CRM takes care of everything.

Once I made that determination, I had to discover a way to differentiate between Create of a new Contract and Renew of an existing Contract.

Here is my solution:

if (context.ParentContext != null &&
    context.ParentContext.MessageName == MessageName.Renew)
{
    return;
}

In the case of a Renewal, we will have a sub-step that is actually the Create.  The main, or parent step is actually the Renew.

By checking to see if our Create step has a parent step, AND if that parent step is a Renew message, then I will exit the plugin and not perform the creation of the Contact Detail record.


This was originally posted here.

Comments

*This post is locked for comments