Automatically Add an Invitee to an Event

Automatically Add an Invitee to an Event

Last Updated on May 19, 2022 by Rakesh Gupta

Big Idea or Enduring Question:

  • How do you automatically share events with an invitee when shared activities is enabled?

This is a continuation of my last article Auto share events from a shared CalendarIn my previous article, I had discussed a use case, whenever an event is created without populating Name and Related To fields, then the flow 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 to add an invitee to an event when shared activities are enabled. 

Objectives:

After reading this blog, you’ll be able to: 

  • Understand what is shared activities
  • Enable shared activities in your org 
  • Add contact or lead as an invitee to the event 
  • Work with Eventrelation object in flow
  • Avoid hard coding of Id
  • and much more

Business Use case

Donna Serdula is working as a System Administrator at Gurukul on Cloud (GoC). They have enabled shared activities to manage their daily activities better and share their calendar with peers. She has received a requirement to auto invitee contact (Brenda David, bdavid@gurukuloncloud.com) in every event. 

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

With shared activities, users can relate up to 50 contacts (but only 1 lead) to an event or a task. 

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

Automation Champion Approach (I-do):

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. 

Let’s take a pause here, and familiarize ourselves with the EventRelation object in Salesforce. It represents a person (a user, lead, or contact) or a resource (such as a conference room) invited to an event.

Field Details
EventId It contains the ID of the event. This value can’t be changed after it’s been specified.
IsInvitee It indicates whether the relation is an invitee.
  • IsInvitee is visible while Shared Activities is being enabled, after it has been enabled, and while it is being disabled.
  • IsInvitee defaults to true while Shared Activities is being enabled, after it has been enabled, and while it is being disabled ifIsInvitee, IsParent, and IsWhat are not set. This configuration ensures compatibility when Shared Activities isn’t enabled and EventRelation represents event invitees only.
  • IsInvitee defaults to false when Shared Activities is enabled if IsParent is set to true.
RelationId It contains the ID of the person (User, Contact, or Lead) or the resource invited to an event. When Shared Activities is enabled, RelationIdcan also contain the ID of an account, opportunity, or other object related to an event.
IsParent IsParent is visible only when Shared Activities is enabled. When false, indicates that the relation is an invitee (a contact, lead, or user). When true, indicates that the relation is a Who or What, as determined by IsWhat field.

Before discussing the solution, let me show you a diagram of a Process 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 a Contact 
  2. Salesforce Flow Steps:
    1. Define Flow properties for record-triggered flow
    2. Create a formula to determine whether the record is created or updated
    3. Add a decision element to check if event is created or updated
    4. Add a get records element to find the Brenda David’s contact  
    5. Add a decision element to check if the contact was found or not 
    6. Add a create records element to add Brenda as an Invitee to an event 

Step 1: Creating a Contact

  1. Create a contact with the following details

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 Action and Related Records
  5. Click Done.

Step 2.2: Formula to Determine Whether the Event is Created or Updated

  1. Under Toolbox, select Manager, then click New Resource to determine whether the record is created or updated. 
  2. Input the following information:
    1. Resource Type: Formula
    2. API Name: forB_IsNew
    3. Data Type: Boolean
    4. Formula: IsNew()
  3. Click Done.

Step 2.3: Using Decision Element to Check if the Event is Created or Updated

Now we will use the Decision element to check if the event record is created or updated. 

  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: {!forB_IsNew
      2. Operator: Equals
      3. Value: {!$GlobalConstant.True}
  5. When to Execute Outcome: If the condition requirements are met
  6. Click Done.

Step 2.4: Adding a Get Record Element to Find Brenda’s Contact

The next step is to use the Get Records element to find contact Brenda’s contact. 

  1. On Flow Designer, below the Created 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 Contact object from the dropdown list.
  4. Select All Conditions Are Met (AND)
  5. Set Filter Conditions
    1. Row 1:
      1. Field: Email
      2. Operator: Equals
      3. Value: bdavid@gurukuloncloud.com
  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.5: Using Decision Element to Check If Contact was Found or Not 

Now, will use the Decision element to check if the previous Get Records element returns a contact 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_Contact}
      2. Operator: Is Null 
      3. Value: {!$GlobalConstant.False}
  5. When to Execute Outcome: If the condition requirements are met.
  6. Click Done.

Step 2.6: Add Action – Create a Record

 The next step is to create a record to invite Brenda to the event, for this, we will use the Create Records element.

  1. On Flow Designer, below the Yes node, click on the +icon and select the Create Records element.
  2. Enter a name in the Label field; the API Name will auto-populate.
  3. Input the following information:
    1. Enter Label the API Name will auto-populate.
    2. How Many Records to Create: One
    3. How to Set the Record Fields: Use separate resources, and literal values
    4. Object: Event Relation
    5. Set Field Values for the Event Relation
    6. Row 1:
      1. Field: EventId
      2. Value: {!$Record.Id}
    7. Click Add Field
    8. Row 2:
      1. Field: RelationId
      2. Value: {!Get_Contact.Id}
    9. Click Add Field
    10. Row 3:
      1. Field: IsParent
      2. Value: {!$GlobalConstant.True}
    11. Click Add Field
    12. Row 4:
      1. Field: IsInvitee
      2. Value: {!$GlobalConstant.True}
  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: Automatically Add an Invitee to an Event {!$Flow.CurrentDateTime}
  6. Click Save

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

Proof of Concept

  1. Create a new event, as shown in the following screenshot:
  2. Check the Related section of the event to find all attendees.

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!

7 thoughts on “Automatically Add an Invitee to an Event

  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.