Create a Person Account For New Email-to-Case

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:

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.)

CreateCase-ProcessBuilder

CreateAccountandAssociateToCase

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).

PersonAccountRecordTypeID.JPG

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.

Convert15to18.JPG

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.

CreateAccountandAssociateToCase

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:

RecordCreate.JPG

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.

varAccountName.JPG

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.

varAccountID.JPG

We also need to create a formula resource , which is reference the custom label created in Step 1.

PersonAccountRecordTypeIDFormula.JPG

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).

RecordUpdate.JPG

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.

varCaseId.JPG

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…

CreateAccountandAssociateToCase.JPG

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.

FlowProperties.JPG

F. Click the “Close” button.

G. On the flows screen, activate the flow.

CreateAccountandAssociateToCase-Activate.JPG

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.

CreateCase-ProcessBuilder

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.”

CreateCase-ProcessBuilder-Properties.JPG

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.

CreateCase-ProcessBuilder-CaseObject.JPG

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.

CreateCase-ProcessBuilder-CriteriaNode.JPG

D. Next, we want to set the immediate action to invoke the flow created in Step 2.

Set the immediate action to the below.