This blog post was inspired by Randi Thompson. Here’s to you, Randi!
Here are a few lessons learned from implementing this use case:
Business Use Case: Addison Dogster is the system administrator at Universal Containers. Steven Moon is the Director of Operations. For the cases that are submitted via Email to Case, Steven would like person accounts automatically created using the record type “Randi.”
Solution: Being the #AwesomeAdmin that Addison is, she was able to solution this declaratively using process builder and flow. Additionally, since she had to reference the person account record type ID when creating the new account, rather than hardcode the Id, she configured a custom label and referenced that in the flow.
Quick Steps:
Pre-requisite: Person accounts are enabled in the org. (Note: This use case will work for creating business account too.)
1. When we create the account in the flow, we will need to set the account record type. We know it is not best practice to hardcode the account record type id in the flow. So, we are going to create a custom record type to hold the person account record type id.
Create a custom label called “PersonAccountRTID” under Setup | Create | Custom Labels in Salesforce Classic or Platform Tools | User Interface | Custom Labels in Lightning Experience.
Use the Person Account Record Type’s SFDC 18 character ID in the value field. Navigate to the person account record type’s record in setup. In the URL, copy the 15 character ID (highlighted in yellow).
Go to this conversion tool: https://www.adminbooster.com/tool/15to18 . Enter the SFDC 15 character ID in the left box, click the 15=>18 button and copy the resulting value (18 character ID) in the right box into the value field of the custom label.
The end result of your custom label should look like this…
Here are the illustrated steps of the above.
2. Let’s create a visual workflow to handle the person account creation and associate the person account to the case, which will be invoked from process builder.
A. First, let’s create person account using the Record Create flow element on the Account object.
Note: You may have more fields you would like to set with this new account. These are just three fields I am setting for this specific use case.
And we store the record ID as variable:
Best practice tip : Don’t forget to provide a description so you and other/future admins know what this record create and resources are used for.
Here are the two variables we created:
The varAccountName will contain the email address that is received via the email-to-case that will be used to create the person account’s last name and email address, passed in through process builder. Note: the Input/Output Type is Input Only. It can also be Input and Output.
The varAccountId will store the newly created person account Id created from this step for use in the next step. Note: The Input/Output Type is private or it can also be set as Input and Output.
We also need to create a formula resource , which is reference the custom label created in Step 1.
Here are the animated steps:
B. Now, let’s create the Record Update flow element to associate the newly created person account to the case. We will update the Case object where the Id equals the varCaseId (which is passed from process builder). We will then update the AccountId field with the varAccountId (created in the previous step).
Best practice tip : Don’t forget to provide a description so you and other/future admins know what this record update and resources are used for.
Here is the variable we created. The CaseId is passed from process builder into flow.
Here are the animated steps:
C. Add the subflow Send Flow Fault Email . For instructions on how to create this, go to Step 2 of blog post: Maximize Maintainability With Process Builder and Componentized Visual Workflow.
D. Set your flow starting point . And connect the flow elements and the fault connectors to match the below…
E. Save as and provide the following properties.
Best practice tip: Provide a description so you and other/future admins know what this flow element is used for.
F. Click the “Close” button.
G. On the flows screen, activate the flow.
3. Lastly, we need to create the process builder that will execute the process upon case creation for cases received via email to case which will then invoke the flow we created in Step 2.
Create a process builder ( Create | Workflows & Approvals | Process Builder in Salesforce Classic or Process Automation | Process Builder in Lightning Experience).
A. Set the process builder properties. We will call this process “Create Case”, provide it a description and select this process to start when “A record changes.”
Best practice tips: Don’t forget to provide a description so you and other/future admins know what this process is used for.
B. We need to select “Case” as the object and we want our process to run when a record is created or edited, click the “Save” button.
C. We need to specify the criteria node that needs to be met to then execute the flow. Let’s call out criteria “email to case” which will execute when “conditions are met” where the case origin equals Web.
D. Next, we want to set the immediate action to invoke the flow created in Step 2.
Set the immediate action to the below.
Save the immediate action.
The end result looks like this…
E. Click on the “Activate” button to activate the process.
Here is the animated steps:
Congrats, you made it to the end! You’ve implemented a process to automatically create a new person account for new cases received as an email to case.
Now, before you deploy the changes to Production, don’t forget to test your configuration changes.