Tracking Unique Data Elements with Custom Objects

I was working with a customer recently who tracks custom data elements per client. For example for Acme Inc, the customer may track a field called "Cost Center", but for Slate Rubble, the customer wants to track "Annual Stone Usage" etc. In essence, the requirement boils down to "how do I track unique name-value pairs per client?"


The answer: create a custom object (in the example here let's call it a NVPair), add 4 fields: an autonumber id, a "Name" textfield, a "Value" textfield, and a Master-Detail relationship to the parent object; say Account or Contact. 

We can then add this object as a related list to our Parent object and business requirement solved.

Nvp

One of the limitation of the solution listed above is that we are using a textfield for the Value attribute. Doing so, may inhibit our ability to use the value in Roll Up Summary fields for example. I am a fan of starting with a simple solution and expanding outwards as the requirements evolve. With this in mind, If this is the case, we can certainly make our NVPair object a little more robust and add ValueType fields to support different data types such as numbers, currency etc. While such a solution certainly adds some more options for dealing with the data contained within the fields, Apex, and Formula fields provide a number of ways of casting values to different types if required. 
tagged Bookmark the permalink. Trackbacks are closed, but you can post a comment.
  • David Van Puyvelde

    Just saw your blog post. An interesting read.
    On the subject of multiple data types for the fields : CMS Force’s Web Forms tackle this.
    Have a look at :
    http://code.google.com/p/sfdc-cmsforce/source/browse/trunk/CMSForce/src/components/inputFormField.component
    http://code.google.com/p/sfdc-cmsforce/source/browse/trunk/CMSForce/src/classes/WebformUtil.cls
    I’m sure you’ll get how it was done by looking at the above. The core of it is a component that can display any field type but renders just one of them depending on the ‘Type’ saved …
    For more details you’ll have to dig in the CMS Force source code that’s available via Code Share …

  • http://sfdc.arrowpointe.com Scott Hemmeter

    A nice touch to this would be to add a new External ID field that’s unique. It would be populated with Workflow with a concatenation of the Parent ID and the Name. This way, you won’t get dupes and you also have a way to integrate name/value pairs with an upsert.
    I’ve dealt with this once before and that helped.

  • http://quintonwall.com Quinton Wall

    Great stuff – I love it when the community collaboratively builds best practices. Thanks!