How To

Create a Person Account For New Email-to-Case


This blog post was inspired by Randi Thompson. Here’s to you, Randi!

Here are a few lessons learned from implementing this use case:

  • Learn how to invoke flow from process builder.
  • Use custom labels to avoid hardcoding Salesforce record type Ids in flow.
  • Provide descriptions, where provided, in Salesforce. This may be tedious step, I know, but your future self will thank you when you are trying to remember what you configured or assist other/future admins when troubleshooting or enhancing what was built. This includes variables, the purpose of a flow, what each flow element does, etc.

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: 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…

  • Short Description: PersonAccountRTID
  • Categories: Flow (I like noting where the custom label is used)
  • Value: This is where you paste the 18 character ID


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.

  • Last Name {!varAccountName}
  • PersonEmail {!varAccountName}
  • RecordTypeID {!PersonAccountRecordTypeIDFormula}

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: {!varAccountId}


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.

  • Action Type: Flows
  • Action Name: InvokeFlow
  • Flow: CreateAccountandAssociateToCase
  • Set the flow variables to the following:
    • varAccountName Reference [Case].SuppliedEmail
    • varCaseId Reference [Case].Id

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.

  1. Submit a new email to case.
  2. Verify that a new person account is created with the email address as the person account’s last name and email address.
  3. Verify that the person account is associated to the case.

Deployment Notes/Tips:

  • The process builder, flow and custom label can be deployed to Production in a change set (or can be deployed using a tool such as Dreamfactory’s Snapshot).
  • You will find the process builder and flow component in a change set under the Flow Definition component type.
  • Update the custom label with the ID of your person account record type ID.
  • Activate process builder and flow as they are deployed as inactive in Production.

4 thoughts on “Create a Person Account For New Email-to-Case

  1. That’s amazing! One question though, If a person account or a contact already exist, will the process builder and flow be triggered, thus creating a “duplicate” person account?

    Liked by 1 person

  2. How do we check the exisitng person accounts. I tried to add a branch to decision with get records. But unable to solve. Can you help.


Comments are closed.