Auto Share Events from a Shared Calendar

Auto Share Events from a Shared Calendar

Last Updated on April 26, 2022 by Rakesh Gupta

Big Idea or Enduring Question:

  • How do you automatically share events from a shared calendar when both WhatId and WhoId are null? 

Calendars can do much more than ensure 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. 

Pre-requisites:

Louis Brooks is working as a Sales Rep at Gurukul on Cloud (GoC). Louis granted, Caroline Bell, another sales rep at GoC, full access to her Calendar. Perform the steps below (In Salesforce Classic) to share your personal calendar: 

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

Business Use Case

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

  1. Event created by – Louis Brooks
  2. Event details Caroline see
  3. Error message received by – Caroline

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 to the preceding screenshot) and then see the image. 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 the Event Detail page because Louis had not populated Related To and/or Name field(s).

Automation Champion Approach (I-do):

There are multiple solutions possible for the above problem. 

  1. You can solve the need by giving all of those people System Admin access. NOT a good solution.
  2. Use Salesforce Flow to find any event that has both of these fields null and update 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 a 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.

This means it is not possible to update the Name (WhoId) field in such cases via Apex Trigger or Salesforce Flow. 

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 131

To solve this requirement, we will use the After-save Record-Triggered Flow. Check out this article to understand why we are using after-save record-triggered flow for this scenario. 

Before diving further, let me also show you a diagram of the Flow at a high level. Please spend a few minutes going through the following Flow diagram and understand it. Let’s begin building this automation process.

Guided Practice (We-do):

There are 2 steps to solve Donna’s business requirement using After-Save Record-Triggered Flow. We must:

  1. Create an Account 
  2. Salesforce Flow Steps:
    1. Define Flow properties for record-triggered flow
    2. Add a decision element to check if both WhoId and WhatId are Null
    3. Add a get records element to find the Sharing event records account
    4. Add a decision element to check if the account was found or not 
    5. Add an assignment element to update whatId

Step 1: Creating an Account

  1. Create an account with the name Sharing event records.

Step 2.1: Define Flow Properties

  1. Click Setup.
  2. In the Quick Find box, type Flows.
  3. Select Flows then click on the New Flow.
  4. Select the Record-Triggered Flow option, click on Create and configure the flow as follows:
    1. Object: Event
    2. Trigger the Flow When: A record is created or updated
    3. Set Entry Criteria
      1. Condition Requirements: None
    4. Optimize the Flow For Fast Field Updates
  5. Click Done.

Step 2.2: Using Decision Element to Check if Both WhoId and WhatId are Null

Now we will use the Decision element to check if both WhoId and WhatId are null. 

  1. On Flow Designer, click on the +icon and select the Decision element.
  2. Enter a name in the Label field; the API Name will auto-populate.
  3. Under Outcome Details, enter the Label the API Name will auto-populate.
  4. Condition Requirements to Execute Outcome: All Conditions Are Met (AND)
    1. Row 1:
      1. Resource: {!$Record.Id}
      2. Operator: In Null
      3. Value: {!$GlobalConstant.True}
    2. Click Add Condition
    3. Row 2:
      1. Resource: {!$Record.WhoId}
      2. Operator: In Null
      3. Value: {!$GlobalConstant.True}
    4. Click Add Condition
    5. Row 3:
      1. Resource: {!Record.WhatId}
      2. Operator: In Null
      3. Value: {!$GlobalConstant.True}
  5. When to Execute Outcome: If the condition requirements are met
  6. Click Done.

Step 2.3: Adding a Get Record Element to Find Sharing event records Account

The next step is to use the Get Records element to find contact with name Sharing event records.

  1. On Flow Designer, below the Both Null node, click on the +icon and select the Get Records element.
  2. Enter a name in the Label field; the API Name will auto-populate.
  3. Select the Account object from the dropdown list.
  4. Select All Conditions Are Met (AND)
  5. Set Filter Conditions
    1. Row 1:
      1. Field: Name
      2. Operator: Equals
      3. Value: Sharing event records
  6. How Many Records to Store:
    1. select Only the first record
  7. How to Store Record Data:
    1. Choose the option to Automatically store all fields
  8. Click Done.

Step 2.4: Using Decision Element to Check If Account was Found or Not 

Now, will use the Decision element to check if the previous Get Records element returns an account record. 

  1. On Flow Designer, click on the +icon and select the Decision element.
  2. Enter a name in the Label field; the API Name will auto-populate.
  3. Under Outcome Details, enter the Label the API Name will auto-populate.
  4. Condition Requirements to Execute OutcomeAll Conditions Are Met (AND)
    1. Row 1:
      1. Resource: {!Get_Account}
      2. Operator: Is Null 
      3. Value: {!$GlobalConstant.False}
  5. When to Execute Outcome: If the condition requirements are met.
  6. Click Done.

Step 2.5: Add an Assignment to Update WhatId on Event 

The next step Is to add WhatId to the event. For this, we will use the Assignment element. 

  1. On Flow Designer, below the Yes node, click on the +icon and select the Assignment element.
  2. Enter a name in the Label field; the API Name will auto-populate.
  3. Set Variable Values
    1. Row 1:
      1. Field: {!$Record.WhatId}
      2. Operator: Add
      3. Value: {!Get_Account.Id}
  4. Click Done.


In the end, Donna’s Flow will look like the following screenshot:

Once everything looks good, perform the steps below: 

  1. Click Save.
  2. Enter Flow Label the API Name will auto-populate.
  3. Click Show Advanced.
  4. API Version for Running the Flow: 55
  5. Interview Label: Auto Share Events from a Shared Calendar {!$Flow.CurrentDateTime}
  6. Click Save

Almost there! Once everything looks good, click the Activate button.

Proof of Concept

  1. Now create an event through Louis’s account and make sure to leave the Name and Related To field blank.
  2. Now login from the Caroline Bell account, and try to access the event TrailblazerDX 2022 created by Louis Brooks.

Formative Assessment:

I want to hear from you!

What is one thing you learned from this post? How do you envision applying this new knowledge in the real world? Feel free to share in the comments below.

Have feedback, suggestions for posts, or need more information about Salesforce online training offered by me? Say hello, and leave a message!

13 thoughts on “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.