Getting Started with Process Builder – Part 63 (Update whoId when shared activities are enabled)

Getting Started with Process Builder – Part 63 (Update whoId when shared activities are enabled)

Last Updated on April 15, 2019 by Rakesh Gupta

This is a continuation from my last article Getting Started with Process Builder – Part 62 (Auto share events from a shared Calendar)In my previous article, I had discussed a use case, whenever an event is created without populating Name and Related To fields, then the process will automatically update such events, and associate it with a particular account to overcome Why can’t I view or edit an Event from a Shared Calendar? issue. This article goes a step ahead and explains, how someone utilizes the Flow and Process Builder to update Name (whoId) when shared activities are enabled. Let’s start with a business use case

Business Use case

Donna Serdula is working as System administrator at Universal Containers. They have enabled shared activities to manage their daily activities better and share their calendar with peers. Louis Brooks has assigned a case to Donna Serdula which states that events created by her are not visible to user Caroline Bell. 

Before going ahead with the solution, Let’s discuss what Shared activities are? 

Let’s take an example,  you create an event on a contact’s activity history. That is quite easy as just populating the field Name with the contact’s name. This is what Salesforce offering since the very early days. You can also add invitees (means you can  more contacts, leads or users to the invitee’s list ) to an event, by navigating to the bottom of the page, as shown in the following screenshot 

Event Invitation
Event Invitation

But you will quickly encounter the limitations, none of the other invitees you have added, have the event on their activity history, as shown in the following screenshot 

No Activity History
No Activity History

In the Summer ’12 release, Salesforce introduced a new feature to overcome this limitation i.e.  Shared Activities or Multiple Contacts on an Activity. Shared activities allow you to search and select multiple contacts at a time, as shown in the following screenshot 

Event Invitation - Shared activities
Event Invitation – Shared activities

Once you have them selected, the field Name will display one of the contacts names and then +5 if you have selected 6 contacts in total. You will now find the event on the activity history of all contacts you have selected.  

Activity History - Shared activities
Activity History – Shared activities

This also applies to Tasks and Emails, where you can select multiple contacts, and the task will be found on each of these contact’s activity history.

How do you enable Shared Activities?

  1. Click on Setup| Build | Customize | Activities | Activity Settings
  2. Select the check box Allow Users to Relate Multiple Contacts to Tasks and Events
  3. Once you are done, click on the Save

Key points to remember 

  1. You can only select up to 50 contacts.
  2. You still can only select one lead, just like without shared activities enabled.
  3. You cannot mix leads and contacts. It’s either one lead or up to 50 contacts.

Solution of above business requirement

To solve the above business requirement, we will update the Name (WhoId  to points a specific contact record) field. Before going ahead, I will suggest you to check Getting Started with Process Builder – Part 62 (Auto share events from a shared Calendar) article to get the context of what I’m talking about. Before going ahead with the solution, you have to understand EventRelation Object. It represents a person (a user, lead, or contact) or a resource (such as a conference room) invited to an event.

Follow the below instructions to create a Flow and Process for the above business requirement

1. First of all, create a contact record with the name Contact to share events
2.
 Navigate to  Setup | Build | Create | Custom Labels. 
Click on New Custom Labels, it will open the new window for you. Now create a new custom label to store the contact record ID we just created (Contact ID for event share), as shown in the following screenshot 

Custom Label – To store contact ID
Custom Label – To store contact ID

3. Click on Name | Setup | App Setup | Create | Workflows & Approvals | Flows
4. Click on New Flow button, and it will open the Flow canvas for you. Now create one text variable {!VarT_EventID} and one formula to store the  Custom Label (Custom Labels are available in Flows. When you create a Formula, the labels are under System and Global Variables), as shown in the following screenshots 

Formula field
Formula field

5. The next step is to update the whoId with contact ID stored in Formula. For this, we will use Record Create element. Drag-and-drop Record Create element (Enter the name Update event primary contact) onto the canvas and map the fields according to below details

  • Select Object EventRelation
  • EventId = {!VarT_EventID}
  • RelationId= {!ContactIDFromCustomLabel}
  • IsParent= {!$GlobalConstant.True}
  • IsInvitee= {!$GlobalConstant.True}, it will look like the following screenshot
Add Contact to an Event
Add Contact to an Event

Finally, your Flow will look like the following screenshot

Add contact to an event
Add contact to an event

6Save the Flow (Type: – Autolaunched Flow) with name Add contact to an event and close the canvas. Don’t forget to Activate the Flow.

Launch a Flow from Process Builder

Our next task is to create a Process Builder on the Event object to start a Flow. To create a Process Builder on the Event object follow the below instructions

1.  Click on Name | Setup | App Setup | Create | Workflows & Approvals | Process Builder
2.
 To create a new process from scratch, click on the New Button available on Process Management page. A pop-up will appear where you have to enter the Name (Use Add contact to an event -PB as name)API Name and Description as shown in the below screenshot

Define Process Properties
Define Process Properties

3. Click on Object node to add object and then select Event object. For the entry criteria, Select only when a record is created, as shown in the below screenshot. Once done, click on the Save button

Evaluation Criteria
Evaluation Criteria

4. The next task is to add Process Criteria. To do this click on Add Criteria, enter NameType of action and set filter conditions as shown in the following screenshot.

  •  [Event].WhoId Is null Boolean True
  •  [Event].WhatId Is null Boolean True
Process Criteria
Process Criteria

5. The next step is to add a Scheduled action to Process. Under Scheduled Actions, click Set Schedule. Set the schedule for 0 Hours after the account CreatedDate.  

Set Schedule

6. Now that you have a schedule added to your process, next step is to add the Flows action to it. For this select action type Flow. Use Field Picker to choose the field [Event].Id, as shown in the following screenshot.

Add action – Flows
Add action – Flows

7. Once done, click on the Save button, it will redirect you to Process canvas. Finally, the Process will look like the following screenshot

Add contact to an event -PB
Add contact to an event -PB

Don’t forget to activate the Process by clicking on the Activate button.

It’s time to test the Process

1) Now login from user’s Louis Brooks account, click on Home tab, and navigate to Calendar section, as shown in the following screenshot 

New Event

2) Now create a new event, make sure to leave Name and Related To field null, as shown in the following screenshot

New Event - Name and Related To Null
New Event – Name and Related To Null

Once done, click on the Save button, it will redirect you to the event detail page. Wait for few minutes and reload the page, it should look like the following screenshot 

Event with Name field populated
Event with Name field populated

3) Now login from user’s Caroline Bell account, and try to access event Automation Hour by Ian Gotts created by Louis Brooks

Proof of concept
Proof of concept

Note: –  I will suggest you guys, implement this first on your developer/sandbox org, test it and then move it to production.

If you have feedback, suggestions for posts or need more information about Salesforce online training program running by me. Say hello and leave and message to me!

 

7 thoughts on “Getting Started with Process Builder – Part 63 (Update whoId when shared activities are enabled)

  1. Hello,

    Thanks for the information, very helpful. I can’t seem to get the Contact to be displayed in the “Name” field on the Event, however. It will only show in the “Hasn’t Responded” related list.

    Am I missing something?

    1. Disregard my above comment! This works great! I was attempting to update the WhoId immediately rather than scheduling it to occur 0 Hours from now.

      Thanks Rakesh, great writeup!

  2. Rakesh,
    Can a similar version of this be applied to automatically add specific users as invitees? Process Builder would be used to set the criteria.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.