Freigeben über


Microsoft CRM Monthly Value of Opportunity vs. Estimated Value of Opportunity

So lets say you have a client in the professional services, government contracting or fundraising organizations. One of the normal requirements for those organizations would be both the “Total” contract value as well as the “monthly” contract value. (So you win a contract for 1,000,000, but it is over a term of 100 years… That contract is worth less than one that is $100,000 over 2 months on a monthly revenue basis.)

One of the conversations I used to have with clients, was which one did you want to do forecasting on, and normally the answer was both. J In 1.2, I used to write a stored procedure to do this, which wasn’t supported. (And only worked online, so any Outlook Clients wouldn’t get updated until they synchronized with the server.)

So this is a VERY simple Jscript that was written for that scenario. And for those of you who write code for a living, please don’t make too much fun of me. J

This snippet goes in the Estimated Value field:

// Declaring some variables

//The Estimated Value is the Estimated Value field from Microsoft CRM OOB

var TotalContractValue = crmForm.all.estimatedvalue.DataValue;

//Length of Contract is a custom field created as a pick list

var TotalContractLength = crmForm.all.new_lengthofcontract.DataValue

//The variable is taking the contract value and dividing it by the length of contract

var Monthly = TotalContractValue/TotalContractLength;

 

//If the contract length is not filled in, we want to just drop the estimated value in the monthly contract value field

if (TotalContractLength == null)

 

{

 

crmForm.all.new_monthlycontractvalue.DataValue = TotalContractValue;

 

}

 

else

{

crmForm.all.new_monthlycontractvalue.DataValue = Monthly;

}

Now that we have that formula working, we also want this to fire on the load of the form and the change of contract length. So I could copy that over and over again, or in reading the SDK, I found a cool short cut. Just call that code from your OnChange in the Length of Contract and OnLoad for the form:

//We are here calling the Monthly Revenue from the Estimated Value On Change Event

estimatedvalue_onchange0()

This is 100% demoware. I am pretty sure that there are some scenarios that I didn’t think about addressing. Attached is the XML File with the code ready to apply to your DEMO System.

 

Because of the way I cheated to write this, if you want longer than a year, add all of the additional months IN ORDER. (i.e., 1 Year 1 Month = 13 in the Database.)

MonthlyContractValue.zip