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 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 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?
- Click on Setup | Build | Customize | Activities | Activity Settings.
- Select the check box Allow Users to Relate Multiple Contacts to Tasks and Events
- 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.
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:
- Create a Contact
- Salesforce Flow Steps:
- Define Flow properties for record-triggered flow
- Create a formula to determine whether the record is created or updated
- Add a decision element to check if event is created or updated
- Add a get records element to find the Brenda David’s contact
- Add a decision element to check if the contact was found or not
- Add a create records element to add Brenda as an Invitee to an event
Step 1: Creating a Contact
Step 2.1: Define Flow Properties
- Click Setup.
- In the Quick Find box, type Flows.
- Select Flows then click on the New Flow.
- Select the Record-Triggered Flow option, click on Create and configure the flow as follows:
- Object: Event
- Trigger the Flow When: A record is created or updated
- Set Entry Criteria
- Condition Requirements: None
- Optimize the Flow For Action and Related Records
- Click Done.
Step 2.2: Formula to Determine Whether the Event is Created or Updated
- Under Toolbox, select Manager, then click New Resource to determine whether the record is created or updated.
- Input the following information:
- Resource Type: Formula
- API Name: forB_IsNew
- Data Type: Boolean
- Formula: IsNew()
- 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.
- On Flow Designer, click on the +icon and select the Decision element.
- Enter a name in the Label field; the API Name will auto-populate.
- Under Outcome Details, enter the Label the API Name will auto-populate.
- Condition Requirements to Execute Outcome: All Conditions Are Met (AND)
- Row 1:
- Resource: {!forB_IsNew
- Operator: Equals
- Value: {!$GlobalConstant.True}
- Row 1:
- When to Execute Outcome: If the condition requirements are met
- 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.
- On Flow Designer, below the Created node, click on the +icon and select the Get Records element.
- Enter a name in the Label field; the API Name will auto-populate.
- Select the Contact object from the dropdown list.
- Select All Conditions Are Met (AND).
- Set Filter Conditions
- Row 1:
- Field: Email
- Operator: Equals
- Value: bdavid@gurukuloncloud.com
- Row 1:
- How Many Records to Store:
- select Only the first record
- How to Store Record Data:
- Choose the option to Automatically store all fields.
- 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.
- On Flow Designer, click on the +icon and select the Decision element.
- Enter a name in the Label field; the API Name will auto-populate.
- Under Outcome Details, enter the Label the API Name will auto-populate.
- Condition Requirements to Execute Outcome: All Conditions Are Met (AND)
- Row 1:
- Resource: {!Get_Contact}
- Operator: Is Null
- Value: {!$GlobalConstant.False}
- Row 1:
- When to Execute Outcome: If the condition requirements are met.
- 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.
- On Flow Designer, below the Yes node, click on the +icon and select the Create Records element.
- Enter a name in the Label field; the API Name will auto-populate.
- Input the following information:
- Enter Label the API Name will auto-populate.
- How Many Records to Create: One
- How to Set the Record Fields: Use separate resources, and literal values
- Object: Event Relation
- Set Field Values for the Event Relation
- Row 1:
- Field: EventId
- Value: {!$Record.Id}
- Click Add Field
- Row 2:
- Field: RelationId
- Value: {!Get_Contact.Id}
- Click Add Field
- Row 3:
- Field: IsParent
- Value: {!$GlobalConstant.True}
- Click Add Field
- Row 4:
- Field: IsInvitee
- Value: {!$GlobalConstant.True}
- Click Done.
In the end, Donna’s Flow will look like the following screenshot:
Once everything looks good, perform the steps below:
- Click Save.
- Enter Flow Label the API Name will auto-populate.
- Click Show Advanced.
- API Version for Running the Flow: 55
- Interview Label: Automatically Add an Invitee to an Event {!$Flow.CurrentDateTime}
- Click Save.
Almost there! Once everything looks good, click the Activate button.
Proof of Concept
- Create a new event, as shown in the following screenshot:
- 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.
Thanks for such nice artice.
But I want to understand Can we remove invitee section from classic or can we audit it?
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?
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!
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.
Yes but the only concern is nothing will work incase of user referenced in any workflow email alert
Good follow up to part 62.
Thank you!
Great writeup!!!!!