4D Blog

Home Product 4D NetKit: Get Google and Microsoft 365 calendar events

4D NetKit: Get Google and Microsoft 365 calendar events

April 24, 2025

Product

Managing calendars and events is crucial for many applications, especially when integrating with popular services like Google Calendar and Microsoft 365. Starting with 4D 20 R9, you can easily retrieve and access calendars and events from these platforms with the new 4D NetKit commands. Whether you’re synchronizing schedules, building calendar-based features, or simply fetching event details, these commands enable seamless integration with Google and Microsoft 365 services.

HDI Get Calendar

In the examples below, we will retrieve the list of all the calendars in a Google Calendar or Microsoft 365 account and all the events associated with the first calendar in the list.

Account connection

As usual, before using Google or Microsoft API, we will create an OAuth 2.0 connection object:

For Google API:

var $oAuth2 : cs.NetKit.OAuth2Provider
var $google : cs.NetKit.Google
$oAuth2:=cs.NetKit.OAuth2Provider.new($googleCredentials)
$google:=cs.NetKit.Google.new($oAuth2)

For Microsoft API:

var $oAuth2: cs.NetKit.OAuth2Provider
var $office365 : cs.NetKit.Office365

$oAuth2:=cs.NetKit.OAuth2Provider.new($microsoftCredentials)
$office365:=cs.NetKit.Office365.new($oAuth2)

Get Calendars list

Before retrieving events of a specific calendar, you need to get the calendar Id. To get it, you can use the .calendar.getCalendars() function to list all the calendars linked to your account. Both APIs provide a method to list calendars, but the parameters and the object returned may differ between Google and Microsoft.

For Google API

// Gets all the calendars 
var $calendars:=$google.calendar.getCalendars()
// For the rest of the example, we'll use the first calendar in the list
var $myCaldendar:=$calendars.calendars[0]

for Microsoft API

// Gets all the calendars 
var $calendars:=$office365.calendar.getCalendars()
// For the rest of the example, we'll use the first calendar in the list
var $myCaldendar:=$calendars.calendars[0]

get eventS list

We can now retrieve the events linked to a specific calendar with the calendar.getEvents() function. Both APIs provide a method to list events, but the parameters and the object returned may differ between Google and Microsoft.

for google API

// Calculates the date range to be used
var $startDate:={date:Current date(); time:?00:00:00?}
var $endDate:={date:Current date()+7); time:?23:59:59?}
// Gets all the event of the selected calendars
var $events:=$google.calendar.getEvents({calendarId: $myCalendar.id; top: 100; singleEvents: True; startDateTime: $startDate; endDateTime: $endDate})

for Microsoft API

// Calculates the date range to be used 
var $startDate:={date:Current date(); time:?00:00:00?}
var $endDate:={date:Current date()+7); time:?23:59:59?}
// Gets all the event of the selected calendars
var $events:=$office365.calendar.getEvents({calendarId: $myCalendar.id; top: 100; startDateTime: $startDate; endDateTime: $endDate})

blank

Conclusion

Managing calendars and events with the new 4D NetKit commands in 4D 20 R9 is easy. Whether you’re working with Google Calendar or Microsoft 365, you can quickly retrieve calendars and events while accounting for the differences in how the two platforms work. For more details, don’t forget to check out the 4D NetKit documentation! 

And this is just the beginning, more commands and features are coming soon to make your calendar integrations even more powerful!

Discuss

Tags 20 R9, 21, 4D NetKit, Calendar, Google, Microsoft 365

Latest related posts

  • April 29, 2025

    Discover your AI-powered writing assistant in 4D Write Pro

  • April 28, 2025

    Unlock the Power of AI with 4D AIKit: Automate, Create, and Innovate

  • April 25, 2025

    Formulas in Label Wizard

Fabrice Mainguené
Fabrice Mainguené
• Product Owner •Fabrice Mainguené joined 4D Program team in November, 2016. As a Product Owner, he is in charge of writing the user stories then translating it to functional specifications. His role is also to make sure that the feature implementation delivered is meeting the customer need.After obtaining a Bachelor degree in Computer Science at CNAM, Fabrice joined a small software publishing company as a Windev developer. Then he worked for different companies in industry and trade areas as a Windev and web developer as well as technical advisor on new features.
  • Deutsch
  • Français
  • English
  • Português
  • Čeština
  • Español
  • Italiano
  • 日本語

Categories

Browse categories

  • 4D View Pro
  • 4D Write Pro
  • 4D for Mobile
  • Email
  • Development Mode
  • 4D Language
  • ORDA
  • User Interface / GUI
  • Qodly Studio
  • Server
  • Maintenance
  • Deployment
  • 4D Tutorials
  • Generic
  • 4D Summit sessions and other online videos

Tags

4D-Analyzer 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R8 20 R9 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Listbox Logs Mail Microsoft 365 Network Objects ORDA PDF Pictures Preemptive Programming Qodly Studio REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor

Tags

4D-Analyzer 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R8 20 R9 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Listbox Logs Mail Microsoft 365 Network Objects ORDA PDF Pictures Preemptive Programming Qodly Studio REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor
Subscribe to 4D Newsletter

© 2025 4D SAS - All rights reserved
Terms & Conditions | Legal Notices | Data Policy | Cookie Policy | Contact us | Write for us


Subscribe to 4D Newsletter

* Your privacy is very important to us. Please click here to view our Policy

Contact us

Got a question, suggestion or just want to get in touch with the 4D bloggers? Drop us a line!

* Your privacy is very important to us. Please click here to view our Policy