- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2019 12:09 PM
I am working on service catalog , Once user request an item in the catalog and it has go through the approval process .
Once the request is approved then a calendar has to create about schedule to pick up in the users calendar and the technician calendar .
How to achieve this ?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2019 10:03 AM
Hi ragz,
In your Workflow, after the approval, I would create a "Run Script" activity that we will create the calendar events in.
The calendar events exist in the following table: user_calendar_event
So we'll create two new records on that table using the GlideRecord API in our Run Script activity. I'm assuming the User, Technician, and Start and End Date of the appointment are variables in your Catalog Item? Let's pretend like they are for this example and call the variables "user", "technician", "start_date", and "end_date".
The code would look something like this then, but you'll have to replace the variable names and any of the other fields you'd like to change to fit your process.
var user = new GlideRecord('user_calendar_event');
user.newRecord();
user.user = current.variables.user;
user.name = 'Technician Appointment';
user.type = 'task_work';
user.task = current.getUniqueValue();
user.start_date_time = current.variables.start_date;
user.end_date_time = current.variables.end_date;
user.insert();
var tech = new GlideRecord('user_calendar_event');
tech.newRecord();
tech.user = current.variables.technician;
tech.name = 'Technician Appointment';
tech.type = 'task_work';
tech.task = current.getUniqueValue();
tech.start_date_time = current.variables.start_date;
tech.end_date_time = current.variables.end_date;
tech.insert();
You can read more about GlideRecord API here: GlideRecord API
Thanks!
Josh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2019 12:55 PM
Hi ragz,
Are you asking to send out a Calendar invite to both user's Outlook calendars?
If so you can do that through a notification, here's the documentation from ServiceNow:
If that's not what you're looking for can you explain a little further?
Thanks
Josh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2019 07:51 AM
Hi Josh,
Thanks for the reply . I need to integrate with outlook as well as put the entry in Service now calendar entry also .
You reply covers the first part . I need how to insert the entry into service now calendar when Technician and user can see the appointments ?
Thanks in Advance

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2019 10:03 AM
Hi ragz,
In your Workflow, after the approval, I would create a "Run Script" activity that we will create the calendar events in.
The calendar events exist in the following table: user_calendar_event
So we'll create two new records on that table using the GlideRecord API in our Run Script activity. I'm assuming the User, Technician, and Start and End Date of the appointment are variables in your Catalog Item? Let's pretend like they are for this example and call the variables "user", "technician", "start_date", and "end_date".
The code would look something like this then, but you'll have to replace the variable names and any of the other fields you'd like to change to fit your process.
var user = new GlideRecord('user_calendar_event');
user.newRecord();
user.user = current.variables.user;
user.name = 'Technician Appointment';
user.type = 'task_work';
user.task = current.getUniqueValue();
user.start_date_time = current.variables.start_date;
user.end_date_time = current.variables.end_date;
user.insert();
var tech = new GlideRecord('user_calendar_event');
tech.newRecord();
tech.user = current.variables.technician;
tech.name = 'Technician Appointment';
tech.type = 'task_work';
tech.task = current.getUniqueValue();
tech.start_date_time = current.variables.start_date;
tech.end_date_time = current.variables.end_date;
tech.insert();
You can read more about GlideRecord API here: GlideRecord API
Thanks!
Josh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2019 12:25 PM
You could actually make this code a little better, I broke it out into two different blocks just to show what I was doing.
But make your function once and then pass in the user, like so:
function createCalendarEvent(user){
var cal = new GlideRecord('user_calendar_event');
cal.newRecord();
cal.user = user;
cal.name = 'Technician Appointment';
cal.type = 'task_work';
cal.task = current.getUniqueValue();
cal.start_date_time = current.variables.start_date;
cal.end_date_time = current.variables.end_date;
cal.insert();
}
//Call the function twice with the user and technician
createCalendarEvent(current.variables.user);
createCalendarEvent(current.variables.technician);
Always try to not repeat yourself when coding 🙂
Best of luck!
Josh