Getting Started with Process Builder – Part 62 (Auto share events from a shared Calendar)

Getting Started with Process Builder – Part 62 (Auto share events from a shared Calendar)

Last Updated on April 15, 2019 by Rakesh Gupta

Calendars can do much more than ensuring you are on time for meetings. They can be a central location for project and event materials and knowledge, inform best practices and even assist with corporate administration. You can grant access to your Calendar in Salesforce, by sharing it with users, groups, all users in a role, or roles and their subordinates. You can choose with whom you want to share your calendar as well as how. Let’s do the groundwork first. 

Ground Work: – Louis Brooks is working as EMEA Sales Rep at Universal Container. Louis granted, Caroline Bell, an APAC Sales Rep at Universal Container, full access to her Calendar.

To share your calendar, perform the following instructions 

  1. Click on Name | My Settings |  Calendar & Reminders | Calendar Sharing 
  2. Click on the Add button to share your Calendar with others.
  3. Select user Caroline Bell and then, click on Add arrow to move Caroline’s name from the Available column to the Share With column.
  4. Use the Calendar Access drop‐down to select how you want to share your Calendar. In this case, select Full Access, as shown in the following screenshot

    Calendar Sharing
    Calendar Sharing
  5. Once you are done, click on the Save button.

Now onwards, whenever Louis Brooks creates an event, it will be automatically shared with Caroline Bell. Let’s start with a business use case

Business Use Case

Donna Serdula is working as System administrator at Universal Containers. Louis Brooks has assigned a case to Donna Serdula which states that events (only a few, for more details of the event, refer the following diagram) created by her are not visible to user Caroline Bell. 

Event created by - Louis Brooks
Event created by – Louis Brooks
Shared Calendar
Shared Calendar
Error message recieved by - Caroline Bell
Error message received by – Caroline Bell

Donna, an Awesome Admin, identified the problem!

Donna searched the Web and found an interesting article about Why can’t I view or edit an Event from a Shared Calendar? 

First, concentrate on point 3 (refer the preceding screenshot) and then see image 1. Findings of Donna’s search to resolve the aforementioned problem: Even though Louis Brooks granted Full Access to Caroline Bell to her Calendar, Caroline was able to view the Event on the Calendar but was not able to access Event Detail page because Louis had not populated Related To and/or Name field(s).

Solution of above business requirement

One real use case from Success Community and credit goes to Rhonda Ross. Check out the success community for more details. 

Solution #1: – As she has mentioned on the thread, you can solve the need by giving all of those people System Admin access. NOT a good solution.

Solution #2: – Another suggestion, She came up with the idea of using Process Builder to find any event that has both of these fields null and updating the name(WhoId) field with a contact record that could be created for this particular purpose.

We will follow the second approach to solving it. Now take pause here and read the known Issue When shared activities is on, task or event triggers that modify whoId or activity relations may not save correctly 

It means if Allow Users to Relate Multiple Contacts to Tasks and Events feature is enabled in an org then 

Any trigger that attempts to modify the who_id field on events or tasks OR attempts to add or remove event or task relations that represent related contacts may not save correctly or may not save at all when the trigger is fired during a UI save. The values for whoId or related contacts set in the UI will take precedence over the values set by the trigger.

Means, it is not possible to update Name (WhoId) field in such cases via Trigger or Process Builder. To solve the above business requirement, we will update the Related To (to points an account record) field. This solution will work for all, whether Allow Users to Relate Multiple Contacts to Tasks and Events feature is enabled or not. 

  • In my next article, I will show you, how to update the Name (WhoId) field when Allow Users to Relate Multiple Contacts to Tasks and Events feature is enabled (Blog 63

There are few possible solutions for the above business scenario, but we will use the Process Builder to solve it. Follow the below instructions to create a Process for the above business requirement

1. First of all, create an account record with the name Sharing event records
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 account record ID we just created (Account ID for event share), as shown in the following screenshot 

Custom Label – To store account ID
Custom Label – To store account ID

3.  Our next task is to create a Process Builder on the Event object to update Related To (What ID) if Name and Related To fields are null. Click on Name | Setup | App Setup | Create | Workflows & Approvals | Process Builder
4.
 To create a new process from scratch, click on the New Button available on Process Management page. A popup will appear where you have to enter the Name (Use Update Related To field as name)API Name and Description as shown in the below screenshot

Define Process Properties
Define Process Properties

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

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

7. The next step is to add an Immediate action to Process. Click on Add Action (Under Immediate actions), Select the type of action to create (In our case Record Updates), and then fill out the fields to define the action, as shown in the following screenshot

Add Action - Record Updates
Add Action – Record Updates

The next step is to map Related To ID field with a custom label. To do so select Formula for Type, as shown in the preceding screenshot. Then click on Build a Formula box and select System Variable dialog, as shown in the following screenshot

Create a Formula - Process Builder
Create a Formula – Process Builder

It will open a popup where you have to select $Label and then select label Account ID for event share, as shown in the following screenshot

Choose a Custom Label
Choose a Custom Label

Once you’re done click on Choose button. In the end, formula for Related To ID field should look like the following screenshot 

Formula
Formula

Once you’re done click on Use this Formula button.

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

Update Related To field
Update Related To field

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
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 open event detail page, as shown in the following screenshot

Event with Related To
Event with Related To

4) Now login from user’s Caroline Bell account, and try to access event World our Toronto 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!

 

13 thoughts on “Getting Started with Process Builder – Part 62 (Auto share events from a shared Calendar)

  1. Great Post Rakesh. On other note i have a question on invoking process builder to Visual workflow.
    1. If my process builder is invoked by Data loader/Integration then 200 records will be updated. From Process builder i am invoking a flow. I want to create a record if an External Id is not populated and update the record if an external id is populated on parent object. In the first pass if there are no records and we try to insert record i am unable to insert the first record and send the rest of 199 records to update path as they are appearing in same transaction. Is there a way to handle this?

Leave a Reply

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