22 thoughts on “Did I Just See You “Hardcode” a Salesforce ID? Aw, Hell No!

  1. To avoid hard-coding IDs in Process Builder, another approach is to have your process call a Flow to lookup the ID. For instance if a process needs a record type ID, it could call a Flow to lookup the ID based on record type name. Do you think this approach has advantages/disadvantages compared to using custom labels or settings?

    Like

  2. Yes, this is the other way to go about it. This post was meant to highlight the use of custom labels, custom settings and custom metadata types. You can only do the lookup in flow but not process builder, validation rules, etc.

    Like

  3. Can you tell me now in Spring 17 how many total of master detail and lookup relationship is available? Thank you!

    Like

  4. Thanks You!- this came in handy today. We have a set of friendly taps on the shoulder to users who create accounts but don’t list themselves as a BD contact (shared record with 5 divisions) and it only applies to one record type.

    Like

  5. Awesome, awesome post! I’ll be referring to this frequently and passing the link on to friends. Thank you!

    Like

  6. Hi,
    Thank you for the useful article. However, I am struggling to reference the custom label which value is User ID in Lightning. When I use following syntax I receive an error ” You cannot use a custom label in the ID field”

    $Label.c.LabelName.

    Please advise. Thank you

    Like

  7. This article needs to be added to all Salesforce Admins’ list of resources! It’s 3 years old and is still valuable information for configuration. Thanks!

    Like

  8. Hi Jenwlee

    I followed the same process to update record type. My question is for Value field you given Record type ID.After deployment to QA do we need to hard cod or update same field with updated record type id.when i tried to retrive its showing record type id from dev sandbox.

    CaseCustomersuccess
    en_US
    false
    CaseCustomersuccess
    0123B00000180Qm

    Like

  9. The point of the custom label, custom setting or custom metadata type in putting the id there is so it is not hardcoded where referenced. I noted that if you can creating the thing you are referencing for the first time, that id will not be the same in the next sandbox and including production. The only time the id is the same is if the id is created in production and brought down to the sandbox via sandbox creation or refresh. So, yes, in your case, you will need to update the Id in all sandboxes and production.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s