How to get Record Type Dynamically
Deepak Raj
Salesforce Consultant | Data Migration Consultant | Salesforce solutions expert, Client satisfaction-focused | Business Anayst
This is one of the common scenarios Salesforce admins wonder "How to get Record Type Dynamically over hard coding Id of the Record type". Well Hardcoding the Id is indeed very simple and it has its own pros and cons.
Is there a way to Dynamically get the Record type?
The Answer is Yes!.
In my use case i am getting a record type called "Invoice" from contact.
Here at the Step 1, I am Getting Contact to initiate the flow
Then i am creating a new variable for storing contact Record type's API name which is "Invoice"
And then i am doing another Get for Record type object and i am using the previously created variable.
On record creation i am using RecordTypeId to make the field
OnDebugging Mode
So you would ask can i use this method only for RecordTypes?
My Answer is No! you can apply the same solution to get queues etc...
For Getting a Queue, just replace RecordType object in get with Group object.
7X Salesforce Certified | Salesforce Developer at Infosys| Namakkal Salesforce Developer Group Leader | #SFDG_NAMAKKAL
1 年Hi Deepak, I have one additional requirement record type also needs to select by Sales-user, so we need to show the record type for the user, and they will select the record type. I can able to get all record types, but some record types don't have access for sales users,I need to show records based on user permission, how can we do this? please share your thoughts...
8x Salesforce Certified Expert
2 年I love this, so many times this was me --> ??♂? when I saw 'CustomerRTID', 'VendorRTId' and so on as separate variables in a flow. Definitely a must use solution if you're using any version control and CI/CD too because without this best practice you're constantly updating IDs after deployments. You should do a post exploring Custom Metadata types and flow. I believe the availability of metadata types in flows is so underutilized and can solve a lot of redundant flow creation as well.