Salesforce Flows - Automated Creation of Account and Contact upon Case submission via Email to Case/Web to Case

Salesforce flows are incredibly powerful tool when it comes to automation in salesforce.Salesforce flows gives immense flexibility and power to the admins to solve complex business problems and enable them to propose solutions which are easy to build, robust and low on maintenance.

We can leverage salesforce flows to address one such business use - Creating customers when a customer raises a case by sending an email to salesforce. We can extend the same scenario for cases which are created by Web to case.

Business Requirement

Whenever a new case is created using Email-To-Case in salesforce, a new account and a contact should be created as well. Agents need not create contact as it hinders their productivity. If there are multiple matching contacts, only then the agent needs to select the appropriate contact.

Solution Proposition

We need to consider three scenarios while defining the solution.

  1. If there are no contacts in the system with the matching email address, a new contact needs to be created.

  2. If there is a contact record with the matching email address, the contact needs to be associated with the case.

  3. If there are multiple contacts available with the given email address, neither a contact to be created nor any contact to be associated with the case.

Fig: Solution Scenarios

Fig: Solution Scenarios

Following should be the proposed solution considering the above scenarios:

  1. Salesforce Flow: We will use salesforce flow for the first scenario.

  2. Salesforce Standard functionality: Nothing needs to be done as Salesforce standard functionality works exactly that way.

  3. Manual Process: Agents need to manually associate the contact with the case. No automation will be required.

Designing the Salesforce Flow

Salesforce Flow Design

Salesforce Flow Design

We will require the following elements in our flow:

Step 1: We need to query the contact records and match them against the SuppliedEmail field from the case.

Screenshot 2021-04-01 at 21.50.28.png
Get Record Element Definition

Get Record Element Definition

Step 2: We need to check the number of matching contacts based on the email id(SuppliedEmail)

Contact Count

Contact Count

Step 3: If the count is less than 1 (which means there are no contacts found),we will create the account first and then create the contact.

Decision whether to create a new contact or not.

Decision whether to create a new contact or not.

Step 4: Create the account and then create the contact.

Account Creation

Account Creation

Contact Creation

Contact Creation

Step 5: Update the case with the newly created account and contact.

Screenshot 2021-04-01 at 21.52.45.png
Update Case Element

Update Case Element

Imagination and problem solving are limitless. The above use case is one such use-case which could be extended to solve multitude of business problems.

Please feel free to let me know in the comments section if the above post was helpful.