• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 787
  • Last Modified:

Use a percentage on a form

Scenario: Our sales staff puts in an estimated value, and probability, which generates a weghted value, when an opportunity is created. They would much prefer entering an actual percentage for the probability, rather than a decimal. How can I set this up and still have CRM calculate the weighted value.

One way which just sprung to mind would be to divide value of the probability by 100, then perform the calculation. I'll test that now, but am still open to suggestions.
  • 3
  • 2
2 Solutions
Sounds like you are on the right track.  Consider a picklist of values that they can choose from (and avoid them saying there is a 69.73%) and these picklist values can have a corresponding pre-created decimal value..

Not sure this helps if they want to get 69.73% granular....
twardnwAuthor Commented:
Hmm, hadn't thought of a picklist, that might work. What should the syntax be? Right now I have in the onChange event for the estimated value and probability:

crmForm.all.new_weight.value = crmForm.all.estimatedvalue.value*crmForm.all.new_probability.value;

and that generates a NaN value in the weighted value on the form.

Just talked it over with our sales guy, he is in favor of doing it as a picklist, so I'll start on that, any hints on the syntax for that?
Basically you're looking for an OnChange or OnSave on the picklist that updates a another value that is either not on the form or hidden on the form.

So if you pick 10%, it will update the other field.
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

twardnwAuthor Commented:
Would I just be referencing it as new_picklist.value ?

Where value 1 = 0%, value 2 = 5%, value 3 = 10%, etc.

How would to code for that work? The attributes I am work with are:

new_weight - this is the calculated value, money type attribute
estimatedvalue - 'money' type attribute
new_opp_probabilitypick - picklist of %'s in 5% increments
new_probability - old probability attribute, I could use this to store the decimal value of each percent.
Two quick answers:

(1) You may want to use a picklist - but associate it with a sales stage.  This way, the % is always associated with the stage that the opportunity is in (this is the typical way that businesses do this).  For example:
Discovery         5%
Presentation    15%
Demo                50%
Quote               75%

Using this approach, you can change the percentage based on a picklist (i.e. Sales Stage) - but allow the user the further control to update it based upon their own evaluation.

(2) The javascript to handle this would be the same either way (you could also use a workflow, which is even easier, but I'll leave that up to you).  JavaScript is below.  You'll need to modify this to update the secondary field that, I think, you want to use for tracking a percentage...but this could should be a suitable starting point for you.  In this particular case, I inserted this code behind the Sales Stage picklist on the Opportunity form.
switch (crmForm.all.salesstagecode.SelectedText)
      case "Prospect":
                crmForm.all.closeprobability.DataValue = 15;
      case "Qualify":
                crmForm.all.closeprobability.DataValue = 20;
      case "Develop":
                crmForm.all.closeprobability.DataValue = 30;
      case "Solution / BPA":
                crmForm.all.closeprobability.DataValue = 50;
      case "Proof":
                crmForm.all.closeprobability.DataValue = 85;
      case "Close":
                crmForm.all.closeprobability.DataValue = 90;
                crmForm.all.closeprobability.DataValue = 0;

Open in new window

twardnwAuthor Commented:
Thanks guys, exactly what I was needing, got it working perfectly now!

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now