When working with Salesforce flows, you often need to refer to static strings.
For example, let’s say you have a custom text field called `Entity` on the account, which you want to set to “Organization” in a flow.
Option 1: When setting the Account record variable, just set `Entity` = “Organization”
This is definitely the quickest and easiest method, but it’s the hardest to maintain. If you later rename “Organization” to “Organisation”, you won’t know in which flows or steps the string is used. Further, this string could be used in multiple steps, so you need to search them all.
Option 2: Create a constant, say ACCNT_ENTITY_ORG = “Organization” and then set `Entity` = ACCNT_TYPE_ORG
This is a slight but noticeable improvement over option 1, as you quickly know whether the string is used or not in the flow. You only need to change the constant once per flow.
Option 3: Create a custom label
This means there’s a single source of truth for the string, and only one place to change it. Custom labels can be referenced directly in flows.
Option 4: Use a custom setting
Similar to option 3, but settings is generally a spot in which you have additional settings related to the project. Custom settings can also be referenced directly from flows.
The takeaway
Choosing between options 2, 3 or 4 depends on the overall project scope and the client’s ability to make future changes. Whichever you end up with, just don’t choose option 1.