1

Our iOS application gathers information about referrals. There are many pick-lists in the application which present several options. Some are single select, some are multi-select. The values change sometimes, some are added, some are deleted, sometimes there are typos. We'd like to use Salesforce to store the values these pick lists present. I've considered (a) storing a JSON array of each pick lists values in a record of a configuration custom object (b) using Salesforce's own pick lists and (c) Creating a One True Lookup Table. Coming from a normalized RDBMS background, none of these choices seem particularly appealing to me. Which is my best choice and are there any better ones? Thanks!

EDIT: I should note that eventually, many of these pick lists will likely require synchronization with external systems

2

Consider looking into Custom Settings. You didn't say how many are many or provided some examples but if I understand your question correctly, you should be able to do this with custom settings. One big advantage of using them is that they are cached.

See: https://help.salesforce.com/apex/HTViewHelpDoc?id=cs_about.htm http://blog.jeffdouglas.com/2010/01/07/using-list-custom-settings-in-salesforce-com/

|improve this answer|||||
2

If the data is to be passed to JavaScript client code, then I suggest designing a simple JSON structure that is easy for the client code to consume. Create the JSON and store it in a public static resource (where there is no size limit unlike custom settings). JSON structures are very conveniently changeable and can carry whatever attributes you need; they are also easy to understand and reasonably self documenting. Each set of picklist values can be a named field whose value is an array of picklist values (or an array of picklist objects holding the name and value and any other attributes you want). No server-side code is needed to query and assemble the data, and the data is fully cacheable at the client-side.

The JSON static resource can be manually created or fully or partly created using Metadata APIs - see Picklist values by record type for AngularJS UI for an example of the latter. The JSON that produces - just an example - has the record type developer name as the first level and then the picklist API field name as the second level holding the array of picklist strings:

{  
  "TermLife":{  
    "Cause__c":[  
      "Accident",
      "Homicide",
      "Illness",
      "Other",
      "Suicide"
    ],
    "PaymentOption__c":[  
      "Lump Sum Payment",
      "Retained Asset Payment",
      ...

If you want to consume the JSON in Apex then JSON.deserializeUntyped makes that pretty easy.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.