Making a Better Contact View for Salesforce Opportunities with No Code

In this post I'll show you step-by-step how to create a custom line item view so that you can easily view and update all the Contacts on an Opportunity, and their roles. We'll be using SmallBuilder Line Items which is free for up to ten users from the AppExchange

 

Whether you've been looking to improve your Contact view for a while, or you just want to practice your customization and admin skills with a no-code tool, this guide will walk you through the steps required so you can improve the way your users view and edit contacts for each opportunity. One of the optional extras uses a short SOQL Where clause to add a filter, but otherwise no code is required at all to set up this custom view (and if you're not comfortable with SOQL you can just copy and paste from this post!).

 

Here's what the standard contact view looks like on a Salesforce opportunity when you expand the full list:

 

And here's one example of a custom view you can achieve with SmallBuilder Line Items:

 

As you can see, there are many fields available in the standard view, but our custom view has additional useful fields. Firstly, we can add custom fields, such as the notes about each contact. But secondly and more powerfully, our custom view also shows fields from multiple objects at the same time, letting you check details about the contact and update the contact role for the current opportunity at the same time (in line!). This is possible because SmallBuilder Line Items gives you the power to connect multiple objects and display fields from all of them on the same screen. Making changes in line and adding multiple contacts at once saves you time going backwards and forwards between various screens. 

 

Getting set up

For this example we don't need to create any custom objects, but optionally you can create custom fields to store any helpful information you need (like the Notes field you can see in the screenshot). We're going to be working with these standard Salesforce objects:

  • Contact 
  • Opportunity - We want to see all our contacts while on the Opportunity screen.
  • Opportunity Contact Role - This junction object connects contacts to opportunities, and also allows you to specify the role the contact plays for that specific opportunity.
  • Account - While the account is not explicitly specified in the opportunity-contact relationship, we can still determine the account that the opportunity and contacts belong to for filtering purposes.

 

If you're following along, make sure you've got SmallBuilder Line Items for free from the AppExchange, as we'll use it to customise the line item view.

 

Creating the line item view in SmallBuilder Line Items

Step 1: Relating objects

First open the SmallBuilder Line Items app, and create a new Line Item Configurator. In the interface that pops up, we have to choose which objects we want to connect with the line item view. To make our contact view for opportunities, let's select the following:

  • Parent object: This is where the line item view will display. We want to see our contacts on the opportunity screen, so choose opportunity.
  • Line item object: This represents the line items displayed in a list, but should be the junction object connecting contacts and opportunities together. So let's choose Opportunity Contact Role.
  • Lookup object: This is the object we will look up to add to the opportunity, so choose Contact.

 

When you're done, this screen should look like this:

 

Step 2: Setting up the lookup selector

The lookup selector is the interface that lets users choose which contacts they want to add to the opportunity (remember, contact is the "lookup object" and opportunity is the "parent object"). We can configure this interface and also set up filters and connect to other objects. 

First let's add the fields we want the user to be able to see: 

  • Name
  • Title
  • Department
  • Reports To
  • Email
  • Phone

You don't need to publish this yet, but this will give you a simple interface like this:

 

This is a good start that lets users see all the relevant fields when they want to add contacts to an opportunity, but you'll notice that lots of irrelevant contacts are shown. It would be great to add a filter to only show contacts which belong to the account which the opportunity also belongs to. We can do this in SmallBuilder Line Items by connecting the Account object. Simply jump back to step one "Relate objects" and add the filter condition under the Lookup object. In this case we only want to see records where the contact's Account ID matches the opportunity's Account ID. We can do this with the following SOQL (feel free to copy and paste):

AccountId = {$Parent.AccountId}

 

If you click the preview button at the top of the screen you should be able to see that now only contacts from the opportunity's account are returned:

 

That wasn't too hard! 

 

Step 3: Setting up the line item editor

The line item editor is where users can view the existing contacts and edit any fields on the junction object - in our case that means the roles that each contact plays in the opportunity. 

You can start by adding the obvious fields from the Opportunity Contact Role object:

  • Is Primary
  • Role

This gives us a simple display like this:

 

But we can do much better that this! A line item view that only shows the contact's role is not that helpful. Wouldn't it be better to bring in relevant information from the Contact object? The best way to do this is to create custom fields on the junction object which simply pull in the values from the contact object. You can add these formula fields easily if you go to Setup > Object Manager > Opportunity Contact Role > Fields & Relationships > New and add a formula field, choosing the text option. When it comes to writing the formula, the easiest way is to go to Advanced and click the Insert Field button. This lets you choose the Contact object and then the field you're interested in. 

 

That's it! You don't need anything more complicated (but optionally, the Report To name will look nicer if you concatenate the first and last name fields). Simple repeat this for each Contact field which you want to display in the line item view. Then hop back to the Line Item Configurator (step 3: Setup Line Item Editor) and add those fields. Then our preview looks much better:

 

Tip: if you want to concatenate the Report To name fields but don't know the first thing about formulas, you can copy this:

Contact.ReportsTo.FirstName & ' ' & Contact.ReportsTo.LastName

 

Adding an in-line notes field to the interface

It would save time if users could make and refer to notes in-line in this interface, instead of clicking through to each contact to check who is the right person to get in touch with! For this example, let's say that the notes are specific to this opportunity, so if you have the same contacts on another opportunity, you can keep separate notes about who to contact for which tasks. Therefore, we shouldn't store these notes on the Contact object, but on the junction object Opportunity Contact Role. This is easy enough to set up - simply create a custom text field directly on the Opportunity Contact Role in the Object Manager. 

 

As a bonus, you can display these notes in our lookup selector so that when the user wants to add new contacts, they can see any relevant notes that were previously saved on the Contact Opportunity Role. To do this, hop over to step 2 "setup lookup selector" and add a virtual field. This creates a column in the Contact data which we can fill in ad hoc with the notes that we'll look up from the Opportunity Contact Role object.

Then link up an internal data source, with the source object set to Opportunity Contact Role, the lookup key set to join on the Contact ID, and connect the Opportunity Contact Role's Note field to your newly created virtual field. When you've done all that it should look like the following: