I have been working on the lead scoring design I blogged about the other day and have made a few changes which I wanted to share. 

One of the best practices I tend to follow when working on the Force.com platform, and Salesforce in general, is that I do my design as I would typically implement it using a traditional language such as Java or Ruby etc. Once I have the general objects and concepts mapped out I then look at the design through the lens of implementation within Force.com; specifically what can I leverage through builder functionality first. This sanity check has regularly saved me a LOT of time and effort when it comes to the implementation of my final design.

For my lead scoring design, it was no different. My initial thought was to build an interpreter, and the screens to maintain it, but after devising a simple entity model of scoring categories which I could assign weights to, and criterion for assigning scores, all that was remaining was a custom field on the lead object.

I initially looked a the recently included vlookup function, intending to write a custom formula to interrogate my scoring categories.  Vlookup is only a new addition to the growing stable of formulas available on the platform, and at this point it is only available for validation rule formulas (There is a Salesforce idea to promote its use beyond validation rules – I already voted on it!)  so I had to look at other options .

As Frank Lloyd Wright once said "An architect's most useful tools are an eraser at the drafting board". He were referring to the architecture of buildings, not software but I always associate this quote with the reality of good design and continuous refactoring. At this stage, I have erased two of my designs, but each time leveraged the learnings to eventually arrive at my current design. This design will use an Apex class to retrieve categories and weights, and store them as custom fields on the lead. I can then add a custom formula field to perform a very simple scoring calculation to achieve my goal, with the intention to refactor out my Apex class at a later stage, if the vlookup function idea is implemented. This approach will help me achieve my best practice of leveraging builder functionality first, as well as solving my current problem in a modular, maintainable manner.

I am currently writing an article to demonstrate the lead scoring best practice solution more fully, but hopefully this post gives you a feel of, not only the final solution, but also the refactoring I encourage when using the force.com platform.


Get the latest Salesforce Developer blog posts and podcast episodes via Slack or RSS.

Add to Slack Subscribe to RSS