Send Work Order Calendar invitations

Sometimes a full-fledged mobile solution for Maximo is needed to really mobilize your workforce. Some others a simpler solution can help without the need of additional infrastructure or costs.

In this article I will show how to send calendar invitations to workers with work order details and reminders for the activities. The calendar event can have a link to Maximo in order to report progress or close the work order using the standard Everyplace or Work Centers interface.

I have developed a script for sending iCal invitations to the owner of the work order. I have tested it with GMail and Outlook clients and works perfectly. However, it should be intended as a base for development and not production-ready.

It can be triggered by a script on the WORKORDER save event or by an escalation to send reminders for approved and scheduled work orders.

#---------------------------------------------------------------------------------
# Script: MXDSENDICAL
# Launch Point: ACTION - MXDSENDICAL
# Send email with iCalendar attachment
#---------------------------------------------------------------------------------

from psdi.server import MXServer
from psdi.util.logging import MXLoggerFactory

from java.util import TimeZone 
from java.text import SimpleDateFormat

# get the custom logger
logger = MXLoggerFactory.getLogger("maximo.meac")

#-------------------------------------------------------------------------------
# global properties

emailTo = mbo.getString("OWNERPERSON.PRIMARYEMAIL")
emailToPersonGroup = ""
emailFrom = MXServer.getMXServer().getProperty("mxe.adminEmail")
emailSubject = mbo.getString("WONUM") + " - " + mbo.getString("DESCRIPTION")
emailMsg = "Please add this event to your personal calendar"

mxHostname = MXServer.getMXServer().getProperty("mxe.hostname")
mxLink = "http://" + mxHostname + "/maximo/ui/maximo.jsp?event=loadapp&value=WOTRACK&uniqueid=" + mbo.getString("WORKORDERID")

#-------------------------------------------------------------------------------

# verifies that start/end dates are set

eventStart = mbo.getDate("SCHEDSTART")
eventEnd = mbo.getDate("SCHEDFINISH")

if eventStart == None or eventEnd == None:
	service.error("mxd", "Scheduled start/end dates must be set")

# build recipient list

emailToList = []

if emailTo != "":
	emailToList.append(emailTo)

if emailToPersonGroup != "":
	emailMboSet = mbo.getMboSet("$PG_EMAILS", "EMAIL", "personid in (select respparty from persongroupteam where persongroup='" + emailToPersonGroup + "')")

	emailMbo = emailMboSet.moveFirst()
	while (emailMbo):
		emailToList.append(emailMbo.getString("EMAILADDRESS"))
		emailMbo = emailMboSet.moveNext()

#-------------------------------------------------------------------------------
# build iCal

sdf = SimpleDateFormat("yyyyMMdd'T'HHmmss'Z'")
sdf.setTimeZone(TimeZone.getTimeZone("UTC"))

dtStamp = sdf.format(MXServer.getMXServer().getDate())
dtStart = sdf.format(eventStart)
dtEnd = sdf.format(eventEnd)

# See PUBLISH event specs: https://tools.ietf.org/html/rfc5546#section-3.2.1

icalbody = (
       "BEGIN:VCALENDAR"
+"\n"+ "PRODID:-//MxDev//NONSGML Event Calendar//EN"
+"\n"+ "VERSION:2.0"
+"\n"+ "METHOD:PUBLISH"

+"\n"+ "BEGIN:VEVENT"
+"\n"+ "UID:" + mbo.getString("WONUM")
+"\n"+ "DTSTAMP:" + dtStamp
+"\n"+ "SEQUENCE:0"

+"\n"+ "ORGANIZER:mailto:noreply@maximo.com"
+"\n"+ "DTSTAMP:" + dtStamp
+"\n"+ "DTSTART:" + dtStart
+"\n"+ "DTEND:" + dtEnd
+"\n"+ "STATUS:CONFIRMED"
+"\n"+ "SUMMARY: Work Order " + mbo.getString("WONUM") + " - " + mbo.getString("DESCRIPTION")

+"\n"+ "DESCRIPTION:Work Order: " + mbo.getString("WONUM")
+"\\n"+ "Description: " + mbo.getString("DESCRIPTION")
+"\\n"+ "Asset: " + mbo.getString("ASSETNUM") + " - " + mbo.getString("ASSET.DESCRIPTION")
+"\\n"+ "Location: " + mbo.getString("LOCATION") + " - " + mbo.getString("LOCATION.DESCRIPTION")
+"\\n"+ "Priority: " + mbo.getString("WOPRIORITY")
+"\\n"+ "Scheduled Start: " + mbo.getString("SCHEDSTART")
+"\\n"+ "Scheduled End: " + mbo.getString("SCHEDFINISH")
+"\\n"+ "<a href=" + mxLink + ">Link to Maximo</a>"

+"\n"+ "BEGIN:VALARM"
+"\n"+ "DESCRIPTION:REMINDER"
+"\n"+ "TRIGGER;RELATED=START:-PT15M"
+"\n"+ "ACTION:DISPLAY"
+"\n"+ "END:VALARM"

+"\n"+ "END:VEVENT"
+"\n"+ "END:VCALENDAR"
)

logger.debug(">>>> iCal body: " + icalbody)

#-------------------------------------------------------------------------------
# send email with attached iCal using MXServer.sendEMail function
# Parameters: to, from, subject, message, attachment, filename

MXServer.getMXServer().sendEMail(emailToList, emailFrom, emailSubject, emailMsg, icalbody, "maximo.ics")

Thanks to my colleague Roberto Caravelli for developing the first prototype of the proposed script.

Send Work Order Calendar invitations

2 thoughts on “Send Work Order Calendar invitations

  1. Hi,
    Thank you for the great knowledge, can you explain the following :
    “…However, it should be intended as a base for development and not production-ready…”
    Why is that ?

    1. I have tested and it works but I do not guarantee it works in all cases.
      It also do not sends updates when the WO is rescheduled for example.

Leave a Reply to user Cancel reply

Your email address will not be published. Required fields are marked *

Scroll to top