How to Dynamically Add CC Recipient’s Address List to Salesforce Flow : Bijay Kumar

How to Dynamically Add CC Recipient’s Address List to Salesforce Flow
by: Bijay Kumar
blow post content copied from  SalesForce FAQs
click here to view original post



**Summary: Automating Email CC List in Salesforce Flow** As a Salesforce admin, there's a need to automate an email notification process. Specifically, when a new high-priority account gets created, an email should be sent to the account owner, including a dynamic CC list. This means that instead of hardcoding email addresses in the flow, the admin wants to make it easy to change these addresses by just updating a list in Salesforce. **Key Details:** 1. **Dynamic CC Recipient Address List**: This feature allows email CC recipients to be dynamically selected based on data from Salesforce records. It keeps email addresses flexible and manageable without altering the flow each time. 2. **Setup Process**: - Create a custom object for leave applications and another for CC emails. - Use Salesforce Flow to automate sending emails with dynamic CC recipients. - Steps include creating a triggering flow, fetching CC email addresses, looping through them, assigning the values, and executing the email action. 3. **Implementation Steps**: - **Start the Flow**: Trigger it when a record is created (e.g., an employee applies for leave). - **Get Records**: Fetch CC email addresses from the custom CC Email List object. - **Loop**: Iterate through the fetched records to gather CC addresses. - **Assign Emails**: Create and format a text variable to hold the concatenated CC email addresses. - **Send Email**: Use the email action element to send out the notification, including the dynamic CC list. - **Debug & Activate**: Always debug the flow before activating it to ensure it works correctly. 4. **Result**: Once implemented, admins can easily update the CC recipient list by modifying the entries in the CC Email List object without needing to directly alter the flow. **Conclusion**: This tutorial provides a comprehensive guide on setting up a dynamic CC email list in Salesforce Flow, enhancing workflow efficiency by allowing easy updates to email addresses. **Additional Context**: Automating processes in Salesforce not only saves time but also minimizes errors. Utilizing Salesforce Flow efficiently can streamline communication within organizations, making it easier for teams to stay informed. **SEO Hashtags**: #Salesforce #SalesforceAdmin #SalesforceFlow #EmailAutomation #DynamicCC #ProcessAutomation #SalesforceTutorial #CCRecipientList #WorkflowAutomation #CRMAutomation


As a Salesforce admin, I have a requirement to automate a process so that whenever a new account gets created with high priority, an email should sent to the account owner. We also need to dynamically provide a CC recipient address list so that whenever we want to change CC email addresses, we will not be required to make changes in the flow. To fulfill this requirement, I created a flow to automate this process.

In this Salesforce tutorial, we will learn how to dynamically add CC recipient’s address list to Salesforce Flow. I will explain it from scratch so that you understand it correctly.

What is Dynamic CC Recipient Address List in Salesforce Flow?

A dynamic CC recipient address list in a Salesforce flow refers to a process where email recipients (for email CC) are dynamically selected based on the data from the records or objects in the Salesforce org. This allows end users to change the CC recipients depending on conditions, user inputs, or the values from related records without hardcoding email addresses.

Let’s understand how the dynamic CC recipient address list works.

When we develop any flow in Salesforce, and after that, when we need to deploy that flow to another Salesforce org. At that time, the end user who is using that org doesn’t know about the flow. For that, we can use dynamic flow so that whenever end users add emails to the list that we created. From there, the flow will take values and add them to the particular element.

Now, I will explain how to develop a flow to dynamically take a cc address list to the email action in the flow. Before that, we will discuss the prerequisites of creating a flow.

Prerequisites:

For example, when an employee applies for leave, an email should be sent to the manager, and also, in that email, some CC email addresses should be there so that they can also receive the same email.

For that, I created a custom object named Apply Leaves__c, and in that object, I added some fields like a leave request form.

How to Dynamically Add CC Recipient's Address List to Salesforce Flow

I have created a custom object named CC Email List__c. In that, I created an Email field named CC Emails__c and then added some emails to the created object.

Dynamically Add CC Recipient's Address List to Salesforce Flow

Now, the scenario is we want to use these emails to the email action element in the CC Recipient Address List field dynamically so that whenever the end user wants to change emails, they can directly change from the object tab instead of modifying the flow.

Create Salesforce Flow to Dynamically Add CC Recipient’s Address List

In the below step, I have explained how to create a flow to add the CC recipient’s address list dynamically.

1. Click on the Setup. -> Home Page. -> In Quick Find Box, Search for Flows. You will see an option under Process Automation. -> Click on Flows.

Click on the New Flow button to create a new flow.

2. We want to create a flow for sending an email in a particular frequency, so we have to select the Record Trigger Fow. Then, click on the Create button.

Now, we will create the following elements in the flow according to the flow diagram displayed in the following Flow Diagram.

Dynamically Add CC Recipient's Address List to Salesforce Flow

1. Start Element:

3. In the start element, we have to select the triggering object. In our scenario, Apply Leave__c is a triggering object because when the user applies for leave at that time, the record gets created, so in the Configure Trigger, we need to select A record is created.

I also added one condition: the Employee Name field should not be Null. Then, I selected Actions and Related Records in the Optimize the Flow option.

Dynamic CC Address List in Salesforce Flows

2. Get Records(Get CC Emails):

4. First, we need to fetch all the CC Email addresses that we stored in the CC email list object. For that, we need to add the Get Records element and enter a Label and API Name.

In the Object field, select the CC email list__c object to fetch the email addresses. Then, as we want to retrieve all emails so, we don’t need to filter records and How many records to store; we need to store All records. We can call this Collection Element because we stored the cc email list object’s records in it.

Use Get Records Element in Salesforce Flow

3. Loop Element(CC Email Loop):

5. Now, we will use the loop element to iterate the records. To add the Loop Element, click on the Add Element icon. Then, enter the element Label and API Name.

Then, select the Collection Variable from Get Records(API Name) and select the iteration direction from the first item to the last item.

Then click on the Done button.

Add Loop Element in Salesforce Flow

New Variable(CCEmailList):

6. To store the CC email addresses, we need to create a new variable. To do that, click New Resource and select the Resource Type as Variable. Enter API Name. Here, I have entered CCEmailList.

Select Data Type as Text. Click on Done.

Create Text Variable in Salesforce Flow

4. Assignment(Assign Emails):

7. In this element, we will assign CC email addresses from the loop element to the text variable that we created. To do so, add the Assignment Element. Then, enter the element Label and API Name.

When we assign the CC email addresses to the text variable, we need to add all emails that are available in the CC email list__c object. After adding it, it will be added as a list, and we need to add a comma (,) after one email. For example, [email protected],[email protected].

For that, in the Set Variable Values to the variable field, select the text variable that we created, Equals operator; in the value, we need to add email from the loop element. Below, I have given the value format.

{!CCEmailLoop.CC_Emails__c},{!CCEmailList}
  • {!CCEmailLoop.CC_Emails__c}: This will fetch the current CC email address, which is in the loop iteration, and add it to the {!CCEmailList} text variable with a comma.
Add Assignment Element in Salesforce Flow

5. Email Action(Send Email to CC Recipients)

8. We need to add an email action element to send an email after the record is created. As you add the email action element, you need to enter the Label, and the API Name will automatically populate. The description is optional; you can give a short intro about this action element.

After that, add the necessary input values. Here, I will explain how the dynamic CC Recipient Address List adds to email action. In this action, we need to select a text variable in which we added CC email addresses in the assignment element.

You can read the whole article on How to Create an Email Template In Salesforce Flow.

Add Dynamic CC Recipients Addresses to Email Action Element in Salesforce Flow

6. Save:

After setting up all labels and conditions, click the Save button to save the flow. For that, we need to enter the Flow Label; the API Name will automatically populate as we click the text box. The Description is optional; we can introduce our flow Shortly.

7. Debug & Activate:

After Saving the flow, click on the Debug button. Then click on the Activate button; always remember to debug the flow before activating it. It’s good practice to use flow.

After debugging the flow, you can see the flow debugged successfully and its path. First, the start element is executed, and then each element is executed one by one. The loop element was executed 2 times because, in the get a record element(collection element), there were two records in CC email list__c. That is why it was executed 2 times and assigned a value to the text variable.

Then, in the Email Action, you can see the details of the values that we provided to the element.

Now, activate the flow and create a record of an object that you selected as the triggering object in this flow.

How to Add Dynamic CC Recipients Addresses to Email Action Element in Salesforce Flow

In this way, we can add a CC recipient addresses list to the email action and automate the process of sending an email to recipients and cc using Salesforce flow.

Proof of Concept:

As any user applies for leave, the record is created in the apply leave object, and the flow is also triggered. After that, an email will be sent to the recipients and the CC addresses that we added dynamically in the Salesforce flow.

Now, when the end user wants to change the CC addresses, they don’t need to make changes in the flo.w; instead, they can change email addresses in the CC Email List__c object, and after that, the email will be sent to changed CC addresses.

Dynamic Email in Salesforce Flow

Conclusion

I hope you have got an idea about how to dynamically add CC recipient’s address list to Salesforce Flow. I have explained it from scratch so that you understand it correctly. After adding the CC recipient’s addresses to the email action in Salesforce flow, if the end user wants to change emails, they can directly change from the object tab instead of modifying the flow.

You may like to read:

The post How to Dynamically Add CC Recipient’s Address List to Salesforce Flow appeared first on SalesForce FAQs.


December 26, 2024 at 05:28PM
Click here for more details...

=============================
The original post is available in SalesForce FAQs by Bijay Kumar
this post has been published as it is through automation. Automation script brings all the top bloggers post under a single umbrella.
The purpose of this blog, Follow the top Salesforce bloggers and collect all blogs in a single place through automation.
============================

Salesforce