How To

Highlight Account Contact Relationship Attribute on the Contact Record [Lightning Experience]

FeatureAcctContactRole

This is the second of four separate posts that will cover each record attribute shown on the flow screen on the Contact record.

Previous blog posts:

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

  • Learn how to use flow to lookup and display data via an embedded flow component on a Lightning record page.
  • 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 Sales. He wants his sales reps and support staff to know whether the Contact they are interacting with is the primary Contact for the Account. Currently, reps and support staff will not know unless they go to the Account record.

Solution: While Addison could possibly create a process that would possibly update a custom primary contact field, this field would not be highlighted to the sales rep or support staff on the Contact record. They would need to know where this field is on the Contact record page. Being the #AwesomeAdmin that Addison is, she was able to solution this creatively using flow screens and embedding the flow component on the Lightning Contact page to highlight this field in its own panel and not create another custom field on the Contact object and a process/flow to go along with it.

While in Classic, you may have used Account Contact Roles, there are no future plans to bring this feature to Lightning Experience. Instead, Salesforce recommends that you replace it with the feature Associate Contact to Multiple Accounts feature. With the feature enablement, a new standard object Account Contact Relationship is created. You have the ability to create custom fields that you want to track on the account contact relationship.  To show the relationship related lists on the account and contact record pages, you need to the Related Contacts and the Related Accounts related lists, respectively. On the Account page, you can remove the contact roles and contacts related lists.

Account-PrimaryContactPointOut.GIF

AdditonalContactDetails-PrimaryContact-Demo

Taking a look back at the consolidated flow, the highlighted boxes are the ones that pertain to this implementation only, along with the GenericSendEmailOnFault subflow.

AdditonalContactDetails-Flow-PrimaryContactRole.GIF

Quick Steps:

1.Create a new custom checkbox field on the Account Contact Relationship object by going to Object Manager | Account Contact Relationship | Fields & Relationships.

Best practice tip: Don’t forget to provide a description so you and other/future admins know what this custom field is used for.

IsPrimaryCustomField.GIF

2. Let’s create a visual workflow to lookup the Contact’s Account ID, then look up the Account Contact Relationship with the Account ID, Contact ID, that has an active, direct relationship. If an account contact relationship record is found that meets the criteria, take the value from the custom IsPrimary field and populate the variable varContactIsPrimary. Then, display the variable’s value on screen.

AdditonalContactDetails-Flow-PremierClient-Revised.GIF

In Lightning Experience, it is found under Process Automation | Flows.

A. Let’s create our flow resources upfront.

Best practice tip: Don’t forget to provide a description so you and other/future admins know what these flow resources are used for.

This variable will store the contact Id that is passed from the flow. Note: for embedded flows, the record Id is passed with this exact variable name, “recordID.” Note: The input/output type needs to be Input Only for the flow to work when called from the flow component.

recordID.GIF

This variable will store the contact’s associated account ID.

varAccountID.GIF

This variable (boolean = checkbox) will store the value of the Account Contact Roles IsPrimary attribute. By default, I am setting this as false.

varContactIsPrimary.GIF

B. Let’s lookup the Contact’s account ID using the Record Lookup flow element on the Contact object where the Id is the value passed from the flow component into the recordID variable. Then, we take the value in AccountID field and store it in the variable varAccountID.

Best practice tip: Don’t forget to provide a description so you and other/future admins know what this record lookup is used for.

AdditonalContactDetails-Flow-PremierClient-RecordLookupContact.GIF

C. Now, we are going to create another Record Lookup flow element on the AccountContactRelation object where the AccountId matches the value in the variable varAccountID, and ContactID matches the value in the variable recordID, IsActive equals true and IsDirect equals true. Then, we take the value in the IsPrimary field and store it in the variable varContactIsPrimary.

Best practice tip: Don’t forget to provide a description so you and other/future admins know what this record lookup is used for.

AdditonalContactDetails-Flow-PrimaryContact-RecordLookupAccountContactRole.GIF

D. Next, we will create a Screen flow element to show the Primary Contact value.

Best practice tip: Don’t forget to provide a description so you and other/future admins know what this screen is used for.

Ensure that under Navigation Options, that you select the option “Don’t show Finish button.” and uncheck the “Show Pause button.”

Then, tab to the Add a Field tab, find the checkbox and drag it to the screen area on the right. Then double-click on the checkbox field and configure it to match the screen below. For the Default Value field, you want to reference the variable varContactIsPrimary.

AdditonalContactDetails-PrimaryContact-ScreenJEN.gif

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

AdditonalContactDetails-Flow-PrimaryContact-Subflow.GIF

F. Set your flow starting point. And connect the flow elements and the fault connectors to match the below…

AdditonalContactDetails-Flow-PrimaryContact-Subflow1.GIF

G. Save as and provide the following properties.

Best practice tip: Provide a description so you and other/future admins know what this flow is.

AdditonalContactDetails-Flow-PrimaryContact-Properties.GIF

H. Click the “Close” button.

I. On the flows screen, activate the flow.

AdditonalContactDetails-Flow-PrimaryContact-Activate.GIF

3. Finally, we need to add the flow component to the Lightning Contact record page. Find the Flow component under the Standard components and drag it to the desired location on the Contact record page. Then, select your flow and check the box that you want to pass the recordID into the flow.

AdditonalContactDetails-PrimaryContact-LightningAppBuilder.gif

Congrats, you made it to the end! You’ve implemented a flow that takes data from the Account Contact Relationship and shows it on the Contact record.

Now, before you deploy the changes to Production, don’t forget to test your configuration changes.

  1. Create two contact roles from the Account record. On the Account Contact Relationship page, specify one contact as the primary contact.
  2. Navigate to the Contact record that is the primary contact. Verify that the Primary Contact? checkbox is checked.
  3. Navigate to the other Contact record that is not the primary contact. Verify that the Primary Contact? checkbox is unchecked.

Deployment Notes/Tips:

  • The flow, custom field and lightning record page can be deployed to Production in a change set (or can be deployed using a tool such as Dreamfactory’s Snapshot).
  • Don’t forget to set FLS on the profile for the custom account contact relationship field Is Primary.
  • You will find the flow component in a change set under the Flow Definition component type.
  • You will need to confirm that all the configuration of a lightning record page change set deployed as expected.
  • Activate the flow as they are deployed as inactive in Production.

 

2 thoughts on “Highlight Account Contact Relationship Attribute on the Contact Record [Lightning Experience]

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s