New campaigns in Salesforce have two default member status values: “Sent” and “Responded”. To customize the values, you can create them manually, set up “campaign templates” to copy the status values or bulk create the values using Data Loader. Now, thanks to one of the Summer ’20 updates, you can easily automate this process using only Salesforce Flow. In this post, I’ll show you how to use Salesforce Flow to create campaign member statuses automatically based on campaign type.
The example
In this post, I’ll be using Salesforce Flow to create the following statuses based on campaign type.
Campaign Type | Campaign Member Status |
---|---|
Online Advertising |
|
|
|
Webinar |
|
Prerequisites
I recommend you map out what status values you want to use for each campaign type as well as which statuses should be marked as default and responded before creating your flow.
Create the flow
Navigate to Setup > Process Automation > Flows and select new flow. Select Record-Triggered Flow from the wizard.
Configure the Trigger to occur when a record is created, and after the record is saved.
Select Campaign as the trigger object.
Add a Decision element to the flow
Drag and drop a decision element onto the page. This is where we will set up the logic to determine what campaign statuses to create for each campaign type.
In this example, I will be creating three outcomes:
- Campaign type = Webinar
- Campaign type = Online Advertising
- Campaign type = Email
Each outcome will use the {!$Record.Type} resource and use the value of the campaign type.
Click the plus sign to add each outcome.
Example: Campaign type = Webinar
Example: Campaign type = Online Advertising
Example: Campaign type = Email
Add create record elements to the flow
Once your decision outcomes have been created, you can add actions to create each campaign member status. Each status for the campaign will use a Create Records element. For example, if you want to create four campaign member statuses for webinars, you will need add four Create Record elements to the flow.
Each create records element will set the following values:
- Create one record
- Use separate resources, and literal values
- Set the value for CampaignId to {!$Record.Id}
- Set a field label
Setting these values are optional:
- HasResponded: I highly recommend setting this as it is helpful for reporting
- IsDefault: There can only be one default campaign status.
- SortOrder: I recommend not setting this value. If your campaign already has values, it can sometimes cause a flow error.
Using my webinar campaign type as an example, here is what my create record steps look like.
Example: Create a campaign member status for invited
Example: Create a campaign member status for registered
Example: Create a campaign member status for attended
Example: Create a campaign member status for no show
Example: All webinar statuses
Here’s what my flow looks like once all my webinar statuses have been added.
Connect the decision element
Connect the decision element to the first create record element and select webinar as the outcome.
Connect the rest of your elements. Now, we are left with a flow that looks like this.
Repeat for the rest of your campaign statuses
Repeat the process above by adding more create record elements to your flow for the rest of your campaign types.
Here’s what my flow looks like once I added the Online Advertising and the Email statuses.
Optional: Delete the default status values
Optionally, you can delete the two default status values (sent and responded) from campaigns automatically by adding a delete record action to your flow.
Drag and drop the delete records element to your flow, select the Campaign Member Status object, and add the criteria.
Connect the delete records element to the last element of each of the flow steps.
Note: Use caution when deleting these statuses. Campaigns must have one status set to responded and one status set to default. If you remove the ‘Sent’ and ‘Responded’ statuses from campaigns you must set these values for one of your custom custom statuses.
Test, test, test
Save and activate your flow. Create new campaigns for each of the campaign types to ensure the statuses are correct.
Questions?
Send me a tweet @jennamolby, leave a comment below, or book a Peer Chat.
Hi Jenna, I realised that I had to update the logic in the Delete element – 1 AND (2 OR 3). Thanks for this flow!
Hey Jenna…this is a great solution. I’m wondering if you could give some advice around updating the Sent and Responded labels to values from the list required. If I try including a delete element to remove the two values, the flow errors for me. I thought it might be because we have to have one of the statuses as the default, but I can’t set the default as true for the status I want as it is already set for Sent. But then Responded (which is set to responded) can’t be updated either for some reason. I know I must be missing something, but not sure what it is. I hope I’m making sense here! Thanks.
Hi Jenna,
This is great and I’ve just implemented it in UAT. One question – the member statuses I’ve been given aren’t in alphabetical order. Do you know how I would order them as I want using the flow? I’ve added them into the flow as needed, but when they get added, it doesn’t seem to be in any particular order. I can’t use the heading to order them (because they aren’t needed in alphabetical order. I hope my question makes sense!.
Thanks,
Sonali
Hi Sonali, Yes, you can set the field called “sortorder” in the flow. This would be in the same step that you set the status names, default value, etc. Hope that helps!
Thanks for this – works great! One question – the flow seems to throw an error if the user is creating a new campaign by using the clone button on an existing campaign which have the statuses. Looks like the “Clone” is attempting the clone the related member statuses as well.
Any ideas for a workaround?
We can’t save this record because the “Add Statuses” process failed. Give your Salesforce admin these details. This error occurred when the flow tried to create records: FIELD_INTEGRITY_EXCEPTION: Name already exists. Enter a unique name.: Member Status.
Hey Joe,
I’m having this same issue, did you find a workaround for it?
Great post for something that’s always been such a pain with Salesforce.
Any chance you have any suggestions on how to use Custom Settings to possibly define the Member Status values for each campaign types to avoid having to hard code this in the flow?
Hi Michael, thank you! I haven’t tried using Custom Settings within a Flow, but it appears that it’s possible: https://www.salesforceben.com/custom-settings-lightning-flows-changing-requirements/.