Schedule a meeting from a record in ServiceNow without plugins

Mukunth R
Tera Contributor

How to send an online meeting invite from ServiceNow by having the start time, end time, list of participants, time zones in the record without teams graph spoke or any other plugins.

Solution:

SCHEDULE A MEETING FROM SERVICENOW WITHOUT THE PLUGINS

 

Requirements:

  • Access to ServiceNow Instance with admin rights
  • Azure Portal access with Microsoft work or school type of account.

 

Description:

The Microsoft Graph teams plugin (not available for PDI) in the store will let you schedule a meeting from ServiceNow but if you want to achieve the functionality without plugin this article would be helpful. There might be several reasons to try this solution, as the graph teams plugin allows to setup the OAuth only by client secret may be if the client is highly secured organization they will not be providing client secret to setup OAuth login for this integration but they will use certificates and if you want a complex business logic to be built with scripts instead of flow designers or try the integration in your PDI where the plugin is not available.

AZURE CONFIGURATION:

Note: Before starting the configuration. Please check the below

Microsoft work or school account with office 365 subscription. (Even if you have office 365 subscription in private account It will not work as we cannot link it to the licenses.

MukunthR_11-1727809838964.png

 


Create a new application in the app registration:

a. Look up for App registrations in the search bar

MukunthR_18-1727809996664.png

b. Create a new application

MukunthR_19-1727810026164.png

c. Register the applications with the following details by naming the application and the other details as filled in the below Image according to your requirements

MukunthR_20-1727810044152.png

d. Provide the necessary API permissions by clicking on add permissions, select Microsoft Graph API and type as application. Search for Calendar and choose
Calendars.ReadWrite Rôle and grant admin consent.
https://learn.microsoft.com/en-us/graph/api/calendar-post-events?view=graph-rest-1.0&tabs=http (to learn more about the API permission)

 

MukunthR_21-1727810065622.png

e. Add the certificate or secret as per your requirements (In my case I am adding the secret).

MukunthR_22-1727810089678.png

End of Azure configuration:

Copy the client secret, client id (application id), tenant id

SERVICENOW CONFIGURATION

 

 a. Create an OAuth setup in ServiceNow by navigating to application registry from the filter navigator. Under What kind of OAuth application? Select connect to third party oauth provider. With the details copied from the azure such as client id, client secret, tenant id fill the details like shown in the below image

MukunthR_23-1727810132119.png

b. Create the OAuth entity profile

MukunthR_24-1727810150556.png

c. Create OAuth Entity scope with the same configuration below and save the record.

MukunthR_25-1727810165664.png

d. Navigate to Connections & Credentials -> Credentials. Create a credential record for the Microsoft graph API and select the OAuth entity profile that you have created. Click get token from the related link to see if the flow is successful if not check the application registry configuration again.

MukunthR_26-1727810197325.png

e. When integration connection is successful. Build your scripts in ServiceNow to schedule a meeting from ServiceNow. It can be done through UI action on the form that executed Scripted REST API or Script include. There are several ways to achieve the functionality, but the best practice is to follow the asynchronous approach and to store the response back from the Graph API for the user to understand and investigate if the result is failed.

SAMPLE SCRIPT TEMPLATE TO TEST THE SOLUTION:

// Fetch the details needed from the form

 var inciNumber = current.getValue('number');

 var startTime = current.getValue('u_start_time');

 var endTime = current.getValue('u_end_time');

 var timeZone = current.getValue('u_time_zone');

 var meetingParticipants = current.getValue('u_meeting_participants');

 var stdt = new GlideDateTime(startTime);

 var fdStartTime = stdt.getDate().getByFormat("yyyy-MM-dd") + "T" + stdt.getTime().getByFormat("HH:mm:ss");

 var etdt = new GlideDateTime(endTime);

 var fdEndTime = etdt.getDate().getByFormat("yyyy-MM-dd") + "T" + etdt.getTime().getByFormat("HH:mm:ss");

 var participants = [];

 var userGR = new GlideRecord('sys_user');

 userGR.addEncodedQuery('sys_idIN'+meetingParticipants);

 userGR.query();

 while (userGR.next()) {

     var attendee = {

         "emailAddress": {

             "address": userGR.getValue('email'),

             "name": userGR.getValue('name')

         },

         "type": "required"

     };

     participants.push(attendee);

 }



//Get the OAuth Token from the application regisgtry

 var oAuthClient = new GlideOAuthClient();

 var params = {

     grant_type: "client_credentials",

     scope: "https://graph.microsoft.com/.default"

 };

 var tokenResponse = oAuthClient.requestToken('Microsoft Graph API', JSON.stringify(params)); // Use the name of the application registry configured

 var token = tokenResponse.getToken();

 

//In the below URL Set the User principle ID from Azure.This will send the invite to participant from this account. This can be set dynamically as well

 var graphApiUrl = 'https://graph.microsoft.com/v1.0/users/[USER PRINCIPLE ID]/calendar/events';

 var subject = 'Incident Meeting - ' + current.number; // Subject of the meeting

 

 // Prepare the request body for the meeting

 var eventBody = {

     "subject": subject,

     "body": {

         "contentType": "HTML",

         "content": "This is a Microsoft Teams meeting scheduled from ServiceNow."

     },

     "start": {

         "dateTime": fdStartTime,

         "timeZone": timeZone

     },

     "end": {

         "dateTime": fdEndTime,

         "timeZone": timeZone

     },

     "location": {

         "displayName": "Microsoft Teams"

     },

     "attendees": participants,

     "isOnlineMeeting": true,

     "onlineMeetingProvider": "teamsForBusiness" //mention the meeting application

 };

 

 //Make the POST request to the Microsoft Graph API to schedule the meeting

 var meetingRequest = new sn_ws.RESTMessageV2();

 meetingRequest.setEndpoint(graphApiUrl);

 meetingRequest.setHttpMethod('POST');

 meetingRequest.setRequestHeader('Authorization', 'Bearer ' + token.getAccessToken());

 meetingRequest.setRequestHeader('Content-Type', 'application/json');

 meetingRequest.setRequestBody(JSON.stringify(eventBody));

 

 //Execute the API request

 var meetingResponse = meetingRequest.execute();

 var meetingResponseBody = meetingResponse.getBody();

 var meetingStatusCode = meetingResponse.getStatusCode();

 

 // Log the results or handle the error in better way for explample by creating a table and relating it to the parent table

 if (meetingStatusCode !== 201) {

     gs.error('Error scheduling Teams meeting. Status: ' + meetingStatusCode + ' Response: ' + meetingResponseBody);

 } else {

     gs.info('Microsoft Teams meeting successfully scheduled. Response: ' + meetingResponseBody);

 }

action.setRedirectURL(current);

RESULT:

MukunthR_27-1727810271543.png

MukunthR_28-1727810280349.png



Thanks,
Mukunth Ragoubady

 

#Integration #Meetings #ServiceNow




1 REPLY 1

Harsh Prateek1
Tera Contributor

Great article, Mukunth! This is a very practical solution for scheduling meetings directly from ServiceNow without relying on plugins. The detailed step-by-step guide makes it easy to follow, and the script example is a great bonus. Thanks for sharing!