Tracking Unique Data Elements with Custom Objects | Salesforce Developers Blog

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.
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. 

Stay up to date with the latest news from the Salesforce Developers Blog