Final Up to date on August 11, 2022 by Rakesh Gupta
Salesforce Stream is without doubt one of the most used declarative instruments to automate enterprise processes in Salesforce. Most of us often create a brand new stream for every requirement. That not solely just isn’t a greatest follow, however, in the long term, it’s a extremely unproductive and unsustainable strategy to managing course of improvement.
Moreover, you threat hitting the governor restrict for those who create a number of flows on one object. Subsequently, my suggestion is to create as minimal as doable flows on every object.
With the latest launch, it’s doable to invoke an autolaunched stream (as subflow) from an After-Save record-triggered stream. With Subflow, you may reuse logic in flows. Construct one autolaunched stream (subflow); name it from a number of flows or a number of motion teams in the identical stream. By utilizing this methodology – of reusing a stream – it can save you time, hold the governor’s restrict at arm’s size and enhance your productiveness!
Pamela Kline is working as a System Administrator at Gurukul on Cloud (GoC). She should replace the Account customized discipline, Out of Enterprise, to True if an Alternative Stage is up to date to Closed Misplaced.
There are numerous methods, as listed, in which you’ll be able to remedy the previous enterprise requirement:
- With one record-triggered stream on the chance object
- Apex Set off
- and rather more
As of now, the very first answer seems good. After just a few weeks, nevertheless, Pamela obtained one other related requirement – to replace the Account customized discipline, Out of Enterprise, to True if Account Ranking is Not . Oh, no! Not once more!
Now she has to re-write the identical logic by making a File-Triggered stream on Account object; that is tedious and time-consuming, to say the least. As a result of, as you may see, in each the necessities, we’re updating Account customized discipline, Out of Enterprise, to True. How about reusing the prevailing logic with Account Stream? Allow us to do it!
Automation Champion Strategy (I-do):
There are just a few doable options for the above enterprise situation. To unravel the previous enterprise requirement (Replace Account customized discipline, Out of Enterprise, to True if an Alternative is up to date to Closed Misplaced), we are going to use the idea of subflow.
Subflow means launch one other stream that’s accessible in your org. A stream that’s launched by one other stream is known as the referenced stream.
We’ve got to create two flows for this, as follows:
- The primary autolaunched stream (It’s invoked by record-triggered stream) it’s used to replace account discipline.
- One other stream (A record-triggered stream) is positioned on the Alternative object, and it’ll fireplace solely when an Alternative Stage is up to date to Closed Misplaced.
The advantage of utilizing this strategy is that for those who get a requirement sooner or later – to replace the Account customized discipline, Out of Enterprise, to True if Account Ranking is Not – then, you name the autolaunched stream out of your Account record-triggered stream with out including one other File Replace on Account stream.
Guided Observe (We-do):
- To start with, create a customized discipline (Out_of_Business__c) knowledge sort Checkbox, on account object.
- Make certain so as to add worth Not for Ranking (drop-down) discipline on the account.
Step 3: Outline Subflow Properties
- Click on Setup.
- Within the Fast Discover field, sort Flows.
- Choose Flows, then click on on the New Stream.
- Choose the Autolaunched Stream (No Set off) choice.
- Click on on Create.
Step 4: Add Motion – Replace Data
The subsequent step is to replace the account Out of Enterprise discipline to True. We’ll use the Replace Data ingredient.
- On Stream Designer, click on on the +icon and choose the Replace Data ingredient.
- Enter a reputation within the Label discipline; the API Identify will auto-populate.
- For The way to Discover Data to Replace and Set Their Values choose Specify situations to determine data, and set fields individually
- Object: Account
- Choose All Situations Are Met (AND).
- Set Filter Situations
- Row 1:
- Area: Id
- Operator: Equals
- Worth: {!varT_AccountId}
- The place varT_AccountId is a textual content variable of sort Enter and Output.
- Row 1:
- Set Area Values for the Alternative Data
- Row 1:
- Area: Out_of_Business__c
- Worth: {!$GlobalConstant.True}
- Row 1:
- Click on Carried out.
In the long run, Pamela’s Subflow Stream will appear like the next screenshot:
As soon as all the things seems good, carry out the steps under:
- Click on Save.
- Enter Stream Label the API Identify will auto-populate.
- Click on Present Superior.
- API Model for Working the Stream: 56
- Interview Label: Subflow: Account Replace
- Click on Save.
Virtually there! As soon as all the things seems good, click on the Activate button.
Step 5: Outline a Grasp File-Triggered Stream to Name a Subflow
- Click on Setup.
- Within the Fast Discover field, sort Flows.
- Choose Flows, then click on on the New Stream.
- Choose the File-Triggered Stream choice, click on on Create
- Object: Alternative
- Set off Alternative Stream When: A file is created or up to date
- Set Entry Standards
- Situation Necessities: None
- Optimize the Stream For Motion and Associated Data
- Click on Carried out.
Step 6: Utilizing Resolution Aspect to Examine if Alternative is Closed Misplaced or Not
Now we are going to use the Resolution ingredient to verify the StageName to make sure that it is the same as Closed Misplaced.
Virtually there! As soon as all the things seems good, click on the Activate button.
Proof of Idea
Subsequent time, when a consumer updates the chance Stage to Closed Misplaced, each the Flows will fireplace and replace the Account Out_of_business__C to True, as proven within the following screenshot:
Formative Evaluation:
I need to hear from you!
What’s one factor you realized from this put up? How do you envision making use of this new information in the actual world? Be happy to share within the feedback under.