Expired Contracts Awaiting Renewal in Dynamics CRM

By | October 16, 2015

Introduction:

Contracts were the traditional way of recording the entitlements or warranties available to the customer for the product.

Microsoft Dynamics CRM supports 3 types of Contracts

Number of Cases

Time

Coverage Date

Contracts have a start and end date and pass through various statesExpired Contracts

Draft – This is when you have created a Contract and not yet invoiced the contract

Invoiced – This is when you Invoice the Contract but the Contract Start and End Dates are in the future.

Active – When the Contract start date has passed but is still before the Contract end date

On Hold – You can temporarily suspend the Contract by putting it on hold

Expired – When the Contract End Date has passed.

Also See : How Sales persons can reach maximum customers in less time.

Contract Renewal

Contracts can be renewed anytime during the contract period or once the contract is expired.Expired Contracts Awaiting Renewal CRM

But when the contract is renewed, OOB CRM does not have a status for “Renewed” that could indicate the Contract has been renewed.Expired Contracts

In CRM it is not easy to find out the contracts that were not renewed, consider a scenario where the service executive has to send an invitation to all the customers who didn’t renewed the contracts.

Here the service executive cannot create a view that will show all the non-renewed contracts from the OOB approach and hence we need to follow the below solution to create a view programmatically for all the non-renewed contracts.

Firstly we need to create the fetchxml to retrieve the non-renewed contracts and then we need to create a view to show these records using the SavedQuery functionality.

FetchXML

“<entity name=’contract’>” +

“<attribute name=’contractid’ />” +

“<link-entity name=’contract’ from=’originatingcontract’ to=’contractid’ alias=’childcontract’ link-type=’outer’ />” +

“<filter type=’and’>” +

“<condition entityname=’childcontract’ attribute=’originatingcontract’ operator=’null’/>”+

“<condition attribute=’statecode’ operator=’eq’ value=’5′ />” +

“</filter>” +

“</entity>” +

“</fetch>”;

In the above query the most important thing to take care is the filter expression applied to remove the renewed contracts from the selection.

Since in this case there is a parental relationship between the original contract and the renewed (New contract created on renewal of the expired contract) contract, so we need to apply the aliased entityname in the filter expression.

After creating the fetchxml we used the SavedQuery feature of CRM to create a view for all the contracts retrieved from the fetchxml above as shown below:

var savedQuery = new SavedQuery()

{

Name = “All Non-Renewed Contracts”,

ReturnedTypeCode = “contract”,

FetchXml = fetchXml,

QueryType = 0,

};

_service.Create(savedQuery);

We can see the All Non-Renewed Contracts as shown below:

Conclusion:

This blog was in response to a query on the forum; however Entitlements are the new enhancements added in Dynamics CRM to overcome the limitations of Contracts and moving forward it would be better to implement Contracts using Entitlements.

Leave a Reply