#1MinuteTip Do you know that you can pass the entire record to recordId resource/variable in Salesforce Flow? All you need to do is to define the data type of the resource as “Record”.
If you weren’t aware of this, then the chances are that you were using “Get Records” element to get the entire record. Well, now you don’t need to do that anymore and make your Flow more efficient.
“recordId” is a special resource in Salesforce Flows that automatically receives the value of the current record Id. For example, if you want to invoke the flow from an “Action” button on an object, there isn’t a way to pass any value to the Flow. In this case if you define a resource of “recordId” in the Flow and mark that as “Available for input”, Salesforce will automatically pass the record Id of the current record to this resource in the Flow.
And if you define this resource’s data type as a “Record”, the entire record will be passed to the variable. Here is an example.
1. Here is screen flow where I have defined the resource “recordId”. Note that the data type of the resource is “Record” and object is “Account”. The resource has been marked as “Available for input”
2. In this screen flow, I have defined a screen component of “Display Text”, that just shows the value of the different fields of the resource defined above. This is to validate that the entire record value is getting passed to the resource “recordId”
3. Next, I have defined an “Action” on Account object and calling the screen flow from this action. As you can see, there is no option to pass any value to the screen flow from action.
4. When I call the screen flow from the “Action” button from an Account record, Salesforce will automatically pass the current record to the “recordId” resource in the flow. This happens automatically behind the scenes. And now, I can see the value of the different fields of the “recordId” variable as defined in the screen flow.
Hi Asagarwal,
What about performance? Is this more effective than through Get Record?
Is there a way to measure it? Any other advantage if this than having one element less?
Best,
Josef
Hi Joseph,
I have not compared the performance but I think using a Get Record element will be more expensive. You can run the flow in debug mode and look at the execution time.
Hi, I was able to access the record (account) with my flow, however when I try to access $User information, I get this error: “Hmm, that didn’t work. Check your internet connection and try again, or refresh the page. If the problem continues, ask your Salesforce admin to contact Salesforce Customer Support.”. It does the same thing with a Get Records for the account information. Can I access both records in the flow?
Hi Barbara,
If by “both records” you mean “User” and “Account” records it is very much possible to access these records in Flow. As the error message suggested, you can try refreshing the page (after clearing browser cache) and see if that works. Please also ensure that the user you are using to run the flow has permissions on the objects and records in those objects.
Hi, I did the same thing, but whenever I defined recordId as record, it failed to pass; but whenever I defined recordId as text, it works. I am using non-profit enterprise version, do you think that could be the case? Thanks for willing to advise/guide.
Hi Jasmine, the Salesforce edition/version will have no bearing on how the recordId works. Can you let me know the following:
1. How and from where are you calling the Flow?
2. Have you checked the ‘recordId’ in Flow to ‘Available for Input’?
3. The ‘recordId’ is defined as ‘record’ of which object?