How Avoid Record Type ID or Queue ID Hard Coding in Salesforce Flow?
One of the most important Salesforce Flow Best Practice is to avoid hard coding Salesforce record IDs in Flow as these record IDs may change when the flow is migrated to another sandbox or production.
Instead of hard coding record IDs you can query them and use it later in the flow.
1. How to get Record Type ID in a Flow?
You can get the Record Type ID by querying the Record Type object and filtering by SobjectType = “Object Name Lead in this example” and Developer Name = “Developer Name of your object, ‘Auto_Loan’ in this example”
2. How to get Queue ID in a Flow?
You can get the Queue ID by querying the Group objects and filtering by Type = “Queue” and Developer Name = “Developer Name of your Queue in this example Hot_Leads”
3. How to use the Queried ID in Create or Update Record Element in a Flow?
You can use the record IDs queried in previous steps in Create or Update Record elements later in the Flow.
4. What if you don’t want to Hard Code the Developer Name?
There may be scenarios where the Queue or Record Type developer names may change between orgs and you don’t want to hard code the developer name in Flow.
You can store the Quote or Record Type developer name in Custom Label, Custom Setting or Custom Metadata Type and refer it in the flow.
- Custom Label – Create a Formula field which will use the Custom Label and use it in the Flow
- Custom Setting – Create a Formula field which will use the custom Label and use it in the Flow
- Custom Metadata Type – Create a Custom Metadata Type, create a field to store the developer name of the Lead Record Type and query the values in the flow
5. Additional Resources
Recommend Articles
- Salesforce Certified User Experience (UX) Designer Exam Guide
- Top Salesforce Interview Questions and Answers for 2023
- Salesforce Industries Summer ’22 Release Top New Features
- Top 7 VSCode (Visual Studio Code) Extensions for Salesforce Developers
- Salesforce Flow Best Practices & Standards Checklist Summer 22