When building flows, it’s common to have input and output variables. Whether passing the current record Id to a screen flow or calling an autolaunched subflow, these variables keep things modular.
Here’s a small tip I haven’t seen often: When using an input variable, only use it once.
For example, let’s say you’re building a subflow that manages an opportunity. The input variable is OpportunityId, which is a text data type.
Then the 1st element in the flow is to get the Opportunity record using OpportunityId. in the rest of the flow, you have two choices when you need to use the Opportunity Id:
- From the input variable, OpportunityId
- From the get element, Get Opportunity.Id
It is better to use the latter. Why?
- You’re probably going to reference other fields on the record. So whether you use Get Opportunity.AcccountId or Get Opportunity.Id, your notation is consistent
- You can reuse OpportunityId without worrying about which opportunity it’s referring to.
- If you change the flow to use another object, or to use a platform event, you only need to change it in one location.
The takeaway
When using input variables, use them once and only once.
Category:
Salesforce