How are key value pairs stored in salesforce?

316    Asked by DanPeters in Salesforce , Asked on May 23, 2023

 In the current system we have key value pairs which are stored in what are called as code tables.

There are quite a lot of code tables. Each has 2 fields one for abbreviation and one for value. For example CA for abbreviation and California for value. What is the efficient way to store key value pairs from these tables in Salesforce? It may not be feasible to create one object per code table just to store values for 2 fields.

Answered by Dipesh Bhardwaj

To have key value pairs stored in salesforce -


You could create a custom object called e.g. "Code" with these fields:
Code Table Name (could shorten this to just Type)
Abbreviation
Valuewhere all rows from the old system from one code table have the same "Code Table Name" value. Then all the old system data can be kept in one custom object.

A custom metadata type - a special form of custom object - could also be used.

Or even just Apex code could be used if the number of values is relatively small and the values will never change. So overall, think about the number of records, whether they change, and who might need to change them which affects how you store them.



Your Answer

Interviews

Parent Categories