Attempting to send a icalendar invite withOUT an email template, and it's not working

rita_m
Tera Guru

Hi -

I'm attempting to set up a iCalendar invite in an email message purely within the Email Notification record (aka WITHOUT using the email template).

(This is NECESSARY if you want to send 2 different meeting invites from the same table - you can only use the method suggested on the ServiceNow wiki if you have a single meeting time per table.   We want to send calendar meetings for change_request for both the planned start date/time and the cab date/time. I couldn't get it to work so I spoke with a developer at Knowledge 14 and he looked at the code and confirmed it wasn't possible to do with the method on the wiki.   )


Things like ServiceNowGuru say it's possible to set up an iCalendar invite without using the email template (and it was the suggested method to send 2 different iCalendar meeting invites from the same table I was given by the SN Dev guy at Knowledge 14).

» Sending iCalendar Invites from any Task table

It doesn't matter if set up your message in the notification or template, but since the out-of-box Change request iCal setup has this in email templates I've decided to do the same for this one for consistency.

However, it doesn't seem to be working!

I've tried making it the most basic iCalendar invite, possible, with absolutely everything hard coded and no variables (although what I pasted below is the more complex version), with no luck.

Every time the new iCalendar email is sent, the message body is blank.

In WORKING iCalendar emails using the email template method, the message body is NOT blank.

The email notification type I'm currently using is Meeting Invitation, the content type is HTML and plain text, and I'm Omitting the watermark.  

BEGIN:VCALENDAR

PRODID:-//Service-now.com//Outlook 11.0 MIMEDIR//EN

VERSION:2.0

METHOD:REQUEST

BEGIN:VEVENT

ATTENDEE;ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:${assigned_to.email}

DTSTART:<mail_script>

var dateTime=current.u_cab_date;

//Split the dateTime to get the time

var date = dateTime.split(" ")[0];

var time = dateTime.split(" ")[1];

var ampm = dateTime.split(" ")[2];

var year = date.split("-")[0];

var month = date.split("-")[1];

var day = date.split("-")[2];

var hour = time.split(":")[0];

var min = time.split(":")[1];

var sec = time.split(":")[2];

gs.log("current.u_cab_date:"+year+month+day+"T"+hour+min+sec+"Z");

template.print(year+month+day+"T"+hour+min+sec+"Z"); //20140502T193000Z

</mail_script>

DTEND:<mail_script>

//yyyy-mm-dd hh:mm:ss

var dateTime=current.u_cab_date;

//Split the dateTime to get the time

var date = dateTime.split(" ")[0];

var time = dateTime.split(" ")[1];

var ampm = dateTime.split(" ")[2];

var year = date.split("-")[0];

var month = date.split("-")[1];

var day = date.split("-")[2];

var hour = time.split(":")[0];

hour = Number( hour)+1;

if (hour < 10){ hour = "0"+hour; }else{ hour = hour+"";}

if (hour == 0){ day = Number(day) + 1;}

if (day < 10){ day = "0"+day; }else{ day=day+"";}

var min = time.split(":")[1];

var sec = time.split(":")[2];

gs.log("current.u_cab_date.hoursAgo(-1):"+year+month+day+"T"+hour+min+sec+"Z");

template.print(year+month+day+"T"+hour+min+sec+"Z"); //20140502T193100Z

</mail_script>

LOCATION:${short_description}

TRANSP:OPAQUE

SEQUENCE:${sys_mod_count}

UID:${sys_id}

DTSTAMP:<mail_script>

//yyyy-mm-dd hh:mm:ss

var dateTime=gs.nowDateTime();

//Split the dateTime to get the time

var date = dateTime.split(" ")[0];

var time = dateTime.split(" ")[1];

var ampm = dateTime.split(" ")[2];

var year = date.split("-")[0];

var month = date.split("-")[1];

var day = date.split("-")[2];

var hour = time.split(":")[0];

var min = time.split(":")[1];

var sec = time.split(":")[2];

gs.log("gs.nowDateTime():"+year+month+day+"T"+hour+min+sec+"Z");

template.print(year+month+day+"T"+hour+min+sec+"Z"); //20140502T192724Z

</mail_script>

DESCRIPTION:CAB meeting for Change ${number} is scheduled for this time period.\n\nClick to view the change: ${URI_REF}\n\nRequested by: ${requested_by}\nConfiguration item: ${cmdb_ci}\nShort Description: ${short_description}\nDescription: ${description}

SUMMARY:Cab for Change ${number}

PRIORITY:${priority}

X-MICROSOFT-CDO-IMPORTANCE:${priority}

STATUS:CONFIRMED

CLASS:PUBLIC

ORGANIZER:MAILTO:ucsfdev@service-now.com

END:VEVENT

END:VCALENDAR



Any advice in getting an iCalendar email working when an email template is NOT used would be vastly appreciated.

Thanks,

-Rita

2 REPLIES 2

jcraneNYC
ServiceNow Employee
ServiceNow Employee

Out of curiosity, why not send two separate notifications that trigger on a specific action or event? Each one can have a different template... the stock out of box template, and then the modified one with the CAB meeting times.


This IS a single notification.   The original notifications still exist and still use the email templates.   This one is the new one.   The mail scripts are because SN only seems to allow 2 automatic translations from SN datetime format to iCalendar datetime format (start and end).   I suppose an alternative would be to add 2 new text fields that are the datetime in iCalendar format and manually update them (with a business rule) after every time the change_request cab date is updated, but that would certainly not be ideal.



Thanks for looking at this!


-Rita