Maximo Open Forum

 View Only

 Add email responses to workorder

  • Everything Maximo
Trisha S's profile image
Trisha S posted 03-24-2026 14:30

Hi,

I have a requirement where when user gets an emil( via communication template) from Maximo, and when he replies to it, the response/ reply should get tagged/ attached to the workorder record.

How do i do this? Also, he wants that right  before when the email is sent , he fills few details in that template and then sends it, so if those details could be in italic or bold and in some colour. 

Can someone help me with this please?

Steven Shull's profile image
Steven Shull

Maximo has a concept called email listener (E-mail Listeners - IBM Documentation) which allows you to setup an email inbox and process inbound emails. These get stored in the COMMLOG table and can create a SR or update a SR record. Out of box, this flow is not supported on WORKORDER or any other object. 

There is a concept called Email Interaction (Email interaction overview - IBM Documentation) built on email listener to support some specific advanced workflows (changing status, completing assignments, etc.). You can use this on WORKORDER, but it won't handle the simple free form email response. Since you mentioned a "template", it's possible you want to capture values that will get copied into the WORKORDER record and might be able to use this. Being completely transparent, I've had very mixed luck with Email Interaction. Simple flows (responding with a 1 or 2 to accept or reject an assignment for example) work OK but the more advanced processing can be impacted by different email formats and clients. 

We've opened ideas in the past to try and get the simple flow to work on any object with COMMLOG support in Maximo rather than just SRs, but it was declined by IBM.

Jade Warren's profile image
Jade Warren

We built an automation script on INBOUNDCOMM (on save -- add & update) that handles some of these cases that Maximo does not handle well / at all:

1) logging e-mails when they don't match w/a person ID

2) adding to closed ticket comm log

3) adding to work order comm log

Here is the script--it is provided "as-is"...

from psdi.server import MXServer;
from psdi.mbo import MboConstants;
from java.util import HashMap;

## get context
mailid =      mbo.getString("MAILID");
obj_key =     mbo.getString("OBJECTKEY");
object_name = mbo.getString("OBJECTNAME");
status =      mbo.getString("STATUS");
subject =     mbo.getString("SUBJECT");
message =     mbo.getString("MSGBODY");
sender =      mbo.getString("CHANGEBY");
vError =      mbo.getString("ERROR");

try:     person = mbo.getUserInfo().getPersonId();
except:  person = "xxx";
    
## flags
ticket_exists = False;
ticket_closed = False;
proceed = True;

create_comm = False;
create_ticket = False;
invalid = False;

if   (mailid != ""):                                   proceed = False;
elif (status in ("ERROR_WO", "COMP_CL", "COMP_NEW")):  proceed = False;
else:                                                  proceed = True;

## record field clean-up
if (mbo.isNull("SUBJECT")):  mbo.setValue("SUBJECT", "<empty subject>", 11L);

## catch external senders
if (sender == "" or sender == "MAXADMIN" or vError.find("Person does not exist") != -1):
    mbo.setValue("CHANGEBY", "EXTERNAL", 11L);
    mbo.setValue("PERSONID", "EXTERNAL", 11L);    

## Clean up undeliverables
if (subject.upper()[:13] == "UNDELIVERABLE"):
	mbo.setValue("STATUS", "COMP_ERR", 11L);
	mbo.setValue("ERROR", "Processed by GRE script", 11L);
	mbo.setValue("MAILID", mailid + "undeliverable_", 11L);
	invalid = True;
	## SR = mbo.getMboSet("LSNRSR").moveFirst();
	## if (SR != None):  SR.delete(11L);

## Truncate SEND TO field
if (len(mbo.getString("SENDTO")) > 255):  mbo.setValue("SENDTO", mbo.getString("SENDTO")[:250] + "...", 11L);

# # # # # END FIELD CLEAN-UP # # # # #

## see if an object key is specified
try:
    s = subject.find("##");
    e = subject.find("##", s + 2);
    
    ## correct situations where the OBJECTKEY wasn't populated due to poor coding
    if (obj_key == "" and s != -1 and e != -1): ## object key (wrapped with double delimiters) is specified but not populated...
        obj_key = subject[s+2:e];
        mbo.setValue("OBJECTKEY", obj_key, 11L);
except:
    ticket_exists = False;

## if we have an object key specified, see if it matches a ticket
try:
    if (not mbo.isNull("OBJECTKEY")):
        tkt_set = mbo.getMboSet("$TKT", "TICKET",    "ticketid = '" + obj_key + "'");
        tkt = tkt_set.moveFirst();
    
        if (tkt != None): ## Check ticket table
            object_name = tkt.getString("CLASS");
            mbo.setValue("OBJECTNAME", object_name);
            ticket_exists = True;
            ticket_closed = tkt.getBoolean("HISTORYFLAG");
            UID = tkt.getLong("TICKETUID");
            varRecord = tkt;
        else:
            ticket_exists = False;
            invalid = True;
            proceed = False;
            mbo.setValue("STATUS", "ERROR_WO", 11L);
except:
    ticket_exists = False;
    invalid = True;
    proceed = False;

# # # # # END OBJECT KEY STUFF # # # # #
if (proceed): ## start taking action against the record   
    if (not ticket_exists and obj_key != ""): ## in this case, a bogus object key was fed to the listener
        mbo.setValue("STATUS", "ERROR_WO", 11L);
        mbo.setValue("ERROR", "Object key " + obj_key + " does not exist in the TICKET table.  Defer to escalation");
        proceed = False;
        mbo.setValue("MAILID", "bad_key_", 11L);
    
    if (ticket_exists) and (
    (status == "INVALID") or 
    (status in ("ERROR", "NEW") and mbo.getString("PERSONID") == "EXTERNAL") or
    (ticket_closed) 
    ):       
        ## in this case, the record exists in Maximo and we DO want a COMM LOG entry
        create_comm = True;
        vError = "Communications log updated by script";
         
    if (not ticket_exists and ((status == "INVALID") or (status in ("ERROR", "NEW") and mbo.getString("PERSONID") == "EXTERNAL"))):
        create_ticket = True;
        create_comm = True;
        vError = "Ticket created by script";
    
    #### ACTIONS - CREATE TICKET ####
    if (create_ticket): ## Create ticket ##
        ctx = HashMap();
        ctx.put("mbo", mbo);
        service.invokeScript("LSTNCRSR", ctx);
        
        obj_key = mbo.getString("OBJECTKEY");
        varRecord = mbo.getMboSet("GRE_SR").moveFirst();
        
    #### ACTIONS - COMM LOG ####        
    if (create_comm): ## Create communication log entry ##
        if (not ticket_closed):
            try:
                c = varRecord.getMboSet("COMMLOG").add(11L);
            except:
                c = mbo.getMboSet("OPEN_TICKETS").moveFirst().getMboSet("COMMLOG").add(11L);
        else:
            c = mbo.getMboSet("OPEN_TICKETS").moveFirst().getMboSet("COMMLOG").add(11L);
            
        src_fields = ["CC", "BCC", "SUBJECT", "CHANGEBY", "CREATEDATE", "SENDFROM", "SENDTO", "REPLYTO", "MSGBODY"];
        dst_fields = ["CC", "BCC", "SUBJECT", "CREATEBY", "CREATEDATE", "SENDFROM", "SENDTO", "REPLYTO", "MESSAGE"];
        
        c.copyValue(mbo, src_fields, dst_fields, 11L);
        c.setValue("INBOUND", 1, 11L);
    
        ## Add attachments to newly created comm log entry
        aset = mbo.getMboSet("DOCLINKS");
        xset = c.getMboSet("DOCLINKS");
        
        a = aset.moveFirst();
        while (a != None):
            x = xset.add();
            fields = ["DOCUMENT", "DOCTYPE", "DOCINFOID"];
            x.copyValue(a, fields, fields, 11L);
            a = aset.moveNext();
        if (vError == ""):
            vError = "COMM LOG updated.";
        else:
            vError = vError + "  " + "COMM LOG updated.";
    
        if (ticket_closed):
            c.setValue("OWNERID", UID, 11L);
            c.setValue("OWNERTABLE", object_name, 11L);
    
    #### FINAL CLEAN-UP ####
    if (create_ticket):
        mbo.setValue("MAILID", "processed_", 11L);
        mbo.setValue("STATUS", "COMP_NEW", 11L);
        mbo.setValue("ERROR", "Ticket created by script", 11L);
    elif (create_comm):
        mbo.setValue("MAILID", "processed_", 11L);
        mbo.setValue("STATUS", "COMP_CL", 11L);
        mbo.setValue("ERROR", "Communications log updated by script", 11L);

The script flags potentially WO-related records and then an escalation runs an action script that processes those...

from psdi.server import MXServer;
from psdi.mbo import MboConstants;
from java.util import HashMap;

## get context
mailid =      mbo.getString("MAILID");
obj_key =     mbo.getString("OBJECTKEY");
sub_key =     "";
object_name = mbo.getString("OBJECTNAME");
status =      mbo.getString("STATUS");
subject =     mbo.getString("SUBJECT");
message =     mbo.getString("MSGBODY");
sender =      mbo.getString("CHANGEBY");
vError =      mbo.getString("ERROR");

## flags
found = False;
record_closed = False;
proceed = True;

if (not mbo.isNull("OBJECTKEY")):
    wo_set =  mbo.getMboSet("$WO",  "WORKORDER", "wonum = '"    + obj_key + "'");
    wo = wo_set.moveFirst();
    
    if (wo != None):
        object_name = wo.getString("WOCLASS");
        mbo.setValue("OBJECTNAME", object_name);
        record_closed = True if wo.getBoolean("HISTORYFLAG") else False;
        UID = wo.getLong("WORKORDERID");
        varRecord = wo;
    else:
		proceed = False;

#### ACTIONS - COMM LOG ####        
if (proceed): ## Create communication log entry ##
    vError = "Communications log updated by script";
    
    if (not record_closed):
        c = varRecord.getMboSet("COMMLOG").add(11L);
    else:
        c = mbo.getMboSet("OPEN_TICKETS").moveFirst().getMboSet("COMMLOG").add(11L);
        
    src_fields = ["CC", "BCC", "SUBJECT", "PERSONID", "CREATEDATE", "SENDFROM", "SENDTO", "REPLYTO", "MSGBODY"];
    dst_fields = ["CC", "BCC", "SUBJECT", "CREATEBY", "CREATEDATE", "SENDFROM", "SENDTO", "REPLYTO", "MESSAGE"];
    
    c.copyValue(mbo, src_fields, dst_fields, 11L);
    c.setValue("INBOUND", 1, 11L);
    
    ## Add attachments to newly created comm log entry
    ownerid = c.getUniqueIDValue();
    aset = mbo.getMboSet("DOCLINKS");
    xset = c.getMboSet("DOCLINKS");
    
    a = aset.moveFirst();
    while (a != None):
        x = xset.add();
        fields = ["DOCUMENT", "DOCTYPE", "DOCINFOID"];
        x.copyValue(a, fields, fields, 11L);
        x.setValue("OWNERID", ownerid, 11L);
        a = aset.moveNext();


    if (vError == ""):
        vError = "COMM LOG updated.";
    else:
        vError = vError + "  " + "COMM LOG updated.";

    c.setValue("OWNERID", UID, 11L);
    c.setValue("OWNERTABLE", object_name, 11L);
    
    mbo.setValue("STATUS", "COMP_CL", 11L);
    mbo.setValue("MAILID", str(c.getUniqueIDValue()), 11L);
    mbo.setValue("ERROR", vError, 11L);
    mbo.getThisMboSet().save();