How To

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:

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

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…

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

CustomLabel.gif

Here are the illustrated steps of the above.

CustomLabel.gif

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.

  • 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}

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:

Flow-RecordCreate.gif

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:

Flow-RecordUpdate.gif

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.

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

CreateCase-ProcessBuilder-InvokeFlow.JPG

E. Click on the “Activate” button to activate the process.

CreateCase-ProcessBuilder-Activate.JPG

Here is the animated steps:

ProcessBuilder-CreateCase.gif

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s