Create a Hyperlink for iCal Business Rule

Community Alums
Not applicable

Hey All, 

 

I hope all is well. I have a quick question. How can I create a hyperlink inside the iCal? 

 

Here is the code: 

(function executeRule(current, previous /*null when async*/) {
	
	
	// -----------------------------------------------
	// If already has iCal file, delete old one first
	// -----------------------------------------------
	var gsa = new GlideSysAttachment();
	var agr = gsa.getAttachments(current.getTableName(), current.sys_id);
	if (agr.next())
		gsa.deleteAttachment(agr.getValue("sys_id"));

	// -----------------------------------------------
	// Create iCal content string
	// -----------------------------------------------
	var iCalString = "";
	iCalString += "BEGIN:VCALENDAR\n";
	iCalString += "[PROD ID OF OUR INSTANCE]";
	iCalString += "VERSION:2.0\n";
	iCalString += "METHOD:REQUEST\n";
	iCalString += "BEGIN:VEVENT\n";
	iCalString += "ATTENDEE;ROLE=REQ-PARTICIPANT;RSVP=FALSE:MAILTO:" + current.contact.email + "\n";
	iCalString += "ORGANIZER:" + "example.gov\n";
	iCalString += "DTSTART:" + formatDateTime(current.window_start) + "\n";
	iCalString += "DTEND:" + formatDateTime(current.window_end) + "\n";
	iCalString += "UID:" + gs.generateGUID() + "\n";
	iCalString += "DTSTAMP:" + formatDateTime(current.sys_created_on) + "\n";
	iCalString += "DESCRIPTION:" + "Please proceed to check-in for your IT Customer Care Center: "+ current.short_description + ". If you can't make your appointment, you can " + "[code] <a href='https://example.gov/esc?id=walkup_visits'>" +"reschedule or cancel it." + "</a>[/code]" + "\n";
	iCalString += "SUMMARY: IT Customer Care Center\n";
	iCalString += "LOCATION:" + current.wu_location_queue.name + "\n";
	iCalString += "END:VEVENT\n";
	iCalString += "END:VCALENDAR\n";
	
	// -----------------------------------------------
	// Write iCal file to appointment record
	// -----------------------------------------------
	var attachment = new GlideSysAttachment();
	attachment.write(current, "wu_appt.ics", "text/calendar", iCalString);
	
	/**
	 * Formats Date/Time field into iCal-compatible string
	 */
	function formatDateTime(dt) {
		var iCalDateTime = dt + "";
		iCalDateTime = iCalDateTime.replace(/[-:]/g, "");
		iCalDateTime = iCalDateTime.replace(/\s/g, "T");
		iCalDateTime += "Z";
		return iCalDateTime;
	}

})(current, previous);

 

 

 

When I download the iCal from the portal it displays this. 

Example V2.PNG

It isn't populating the URL. I feel like I am missing something. What am I missing in the code? 

It should look like this: "If you can’t make your appointment, you can reschedule or cancel it."

1 ACCEPTED SOLUTION

Community Alums
Not applicable

Here is the solution if anyone wants to know. You will use "X-ALT-DESC;FMTTYPE=text/html:"

 

 

Here is the link: https://blog.worldline.tech/2023/06/20/html-icalendar.html 

View solution in original post

1 REPLY 1

Community Alums
Not applicable

Here is the solution if anyone wants to know. You will use "X-ALT-DESC;FMTTYPE=text/html:"

 

 

Here is the link: https://blog.worldline.tech/2023/06/20/html-icalendar.html