Salesforce – Google Calendar Integration tips and tricks

on

|

views

and

comments

Hello friends, In this post, I will show you how you can integrate Salesforce with Google Calendar so that Salesforce user could aware of all upcoming events and tasks!

Below is the list of all the tasks that we will do in this post to do Integrate Google Calendar with Salesforce.

  1. Create a public List type Custom SettingGoogleCalenderInfo” to store the access/refresh token and expiry time (in Seconds).
  2. Enable Google Calendar API and create an App to get the Consumer Key and Consumer Secret
  3. Create VF page Apex Class to make the callout and store Access/Refresh Token into Custom Setting.
  4. Create Another VF page which will fetch all the List of Calendar Available into your Calendar and create a new Calendar From Salesforce.

Create New Custom Setting: –

Login into Your Salesforce Org and go to Setup -> Develop -> Custom Settings -> New

See below image for the field names and data types

Custom Setting

Create Required VF pages and Apex Classes: –

  • Open Developer Console and Create 2 Apex Classes GoogleCalenderApi and GoogleCalendarActionsController.
  • Now, Create 2 VF pages “GoogleCalendarActions” and “GoogleCalenderoAuth”
  • You will get the Complete code for All the pages and Apec Classes From Here copy the code and paste in your pages/classes.

Do Enable Google Calendar API and Settings: –

Go to  Using OAuth 2.0 to Access Google APIs and you will get Detailed Information about authentication process.

Go to Google API Console, Credentials -> Create Credentials -> oAuth Client Id

1

Application Type -> WEB

Authorized redirect URIs -> URL To Your VF page “You already have created the VF page if not follow the above steps and create both the pages with classes”

Open “GoogleCalenderoAuth” VF page, Click Preview and Copy the URL that URL is the Redirect URI paste that URL here.

Note: – You also need to replace “redirect_uri” variable in GoogleCalendarAPI class with your VF page URL. 

VF PAGE Preview.png

Now, Click Create, a Pop up with Client Id and Client Secret will open

2

3

Copy both Client Id and Client Secret in any text Editor like notepad++, notepad, or any editor.

Now, Open GoogleCalenderApi class replace consumerKey with your Client Id and clientSecret with your Client Secret.

Now, as we have done all the necessary steps and it’s show time.

Open “GoogleCalenderoAuth” VF page, preview it Page will look like below

VF page.png

Click “Connect With Calendar” you will be redirected to Gmail Login, Login with your Gmail, Grant Access to Application. You will get back to the same Page and Now Click “Get Access Token” a new Page “GoogleCalendarActions” will open.

VF page.png

VF page

First, we will create a New Calendar, Enter “Testing Google API ” and then Create New Calendar. You will get a Success Message with the response.

Create New Calendar

Now, List All Calendars will list all the calendars that are available to your Account.

List All Calendars.png

Note: – Using the Above Code of “GoogleCalenderoAuth” Page and “GoogleCalenderApi” Apex Class you can integrate with Any Google API. You only need to make a minor change which is the value of the calendar_Scope variable in GoogleCalenderApi class, use the scope of the API that you want to Connect. You will get the scope of all the APIs OAuth 2.0 Scopes for Google APIs.

Any Queries come in the comment section.

 

Please do like and share the same as sharing is caring 🙂

 

 

Amit Singh
Amit Singhhttps://www.pantherschools.com/
Amit Singh aka @sfdcpanther/pantherschools, a Salesforce Technical Architect, Consultant with over 8+ years of experience in Salesforce technology. 21x Certified. Blogger, Speaker, and Instructor. DevSecOps Champion
Share this

Leave a review

Excellent

SUBSCRIBE-US

Book a 1:1 Call

Must-read

How to Utilize Salesforce CLI sf (v2)

The Salesforce CLI is not just a tool; it’s the cornerstone of development on the Salesforce Platform. It’s your go-to for building, testing, deploying, and more. As one of the most important development tools in our ecosystem

Save the day of a Developer with Apex Log Analyzer

Table of Contents What is Apex Log Analyzer? Apex Log Analyzer, a tool designed with Salesforce developers in mind, is here to simplify and accelerate your...

Salesforce PodCast

Introduction Hey Everyone, Welcome to my podcast, the first-ever podcast in India for Salesforce professionals. Achievement We are happy to announce that we have been selected as Top...

Recent articles

More like this

4 COMMENTS

  1. Hi, how can we integrate a custom event object with attendies list to Google Calendar along with a Zoom meeting link.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

5/5

Stuck in coding limbo?

Our courses unlock your tech potential