Summary:
Guidance on how to create a Salesforce Flow to automatically add companies to monitoring if they meet certain criteria.
In the example for this article, any company that has a billing country of Great Britain will automatically be added to the selected portfolio. You will need to adjust certain settings to make this applicable for your own organisation.
Solution:
For more guidance on how to Create a Salesforce Flow to Auto Add a Company to a Monitoring Portfolio, please view this interactive demonstration.
You can also follow the below steps to create the flow:
- In your Salesforce setup area, navigate to Flows. This can be done by searching "Flows" in the Quick Find box on the top left of the screen.
- Click on New Flow on the top right of the screen
- Choose your flow creation option. In this example, we are choosing Start From Scratch
- Click Next
- Select the Type of Flow. In this example, we are using a Record-Triggered Flow
- Start configuring your flow triggers, for the flow we are creating we will be setting the following configurations:
- Object: Any standard or custom object that has a related lookup to an Account*
- Trigger the Flow When: A record is created or updated*
- Set Entry Conditions - Condition Requirements: All Conditions Are Met (AND)*
- Field: BillingCountry*
- Operator: Equals*
- Value: GB*
- When to Run the Flow for Updated Records: Only when a record us updated to meet the condition requirements*
- Actions and Related Records ticked
- Tick the Run Asynchronously path field. Apex Actions will only trigger if the process runs asynchronously
- Click Save
- Name your Flow
- Click Save
- In Run Asynchronously section of the flow, click the + button that sits above the End action
- Select the Assignment option
- Name your Assignment Rule
- Set your Variables. Variables are a used in Flow to store data temporarily for use later in the workflow, like text, numbers, or record ID's.
- In the Variable field, select Variable from the resource list
- Name your variable - This should be the name of the Input field of your decision model (e.g. Sales Value)
- Select your Data Type. You will need to select the Apex Defined option.
- Select Done
- Select the Variable field again. A key value pair is a set of two linked items: a key (name of input field) and a value (amount request), an example would be 'Sales Value (key) and 10,000 (value)'
- In the Variable field, select the SalesValuePair value
- Then select Key. The value should read "SalesValuePair >key"
- In the Value field, select the API name value for the input field. This needs to be correct or the action will fail. In this example, we are using the API Key, which is called CreditAmount (the input label visible when submitting a decision is "Sales Value").
- Click on the + Add Assignment button
- In the new Variable field, select the existing variable. This will be SalesValuePair
- In the same field, select the "value" property. The field should read "SalesValuePair > value"
- In the Value field, set the value data. In this example we are using the Credit Limit from the Account that's running this flow. This can any field on the Account record or you can enter a value that will used each time e.g. 10,000. In this field, we are searching for "Triggering Account" then "Credit Limit". The Value field should read "Triggering Account > Credit Limit"
- Repeat these steps to continue adding Variables. You will need to repeat these steps to add the Model Configuration Tree ID, and also the Decision Models unique GUID. Overall, your variable values should have the below configuration:
Variable Operator Value SalesValuePair >key Equals CreditAmount** SalesValuePair > value Equals Triggering Account > Credit Limit TreeNamePair > key Equals treeName TreeNamePair > value Equals Salesforce Demo* (your own tree name) TreeIDPair > key Equals Tree ID TreeIDPair > value Equals CODE* (Your own API code)
- Next, we need to add a second Assignment into the main flow. Within the flow, underneath the first Assignment, click the + button.
- Select the Assignment option again.
- In the Set Variable Values section add in the following information to the variables using the same steps as above. The variable values in this assignment will be:
Variable Operator Value UserInputsVar Add SalesValuePair UserInputsVar Add TreeIDPair UserInputsVar Add TreeNamePair
- In the flow, under the two newly added assignments, click the + button and add an Action. This flow action has a lightening bolt symbol.
- Search the available actions in the right side of the screen and select "Run Decision Action"
- Name your action and provide a description
- Assign the input parameters. Here you'll need to add the user variable collection. This is named "UserInputsVar"
- In the Salesforce ID field, Select the Triggering Account option, then select Account ID. The field should read "Triggering Account > Account ID"
- Click Save on the top right of the screen
- Click Activate on the top right of the screen
* The fields where we are setting entry conditions are configurable to your own needs. the example we have set is for a record that has a billing country in Great Britain. You will need to change these to suit your own requirements.
**In this example, creditAmount is the API key representing the requested amount (not the Input Label that's visible when manually running a decision). This field is required when submitting a decision. When making a decision request, you must use the correct API key names. The number of key-value pairs will vary depending on the decision model you are using (Custom vs. Template).