Blog for IBM Maximo,SCCD 7.5 ,Automation Script,MBO and TADDM solutions .

Incident Email Interaction Add Work Log

Incident Email Interaction Add Work Log


from psdi.mbo import SqlFormat
from psdi.server import MXServer
from psdi.common.emailstner import LSNRUtil
from psdi.common.emailstner import LSNRHTMLTagRemover

print "INC_MFMAIL_ADDWORKLOG - BEGIN"

objectkey = mbo.getString("OBJECTKEY")
strclass = mbo.getString("OBJECTNAME")
personid = mbo.getString("PERSONID")
subject = mbo.getString("SUBJECT")
tmpbody = mbo.getString("MSGBODY")

tagRemover = LSNRHTMLTagRemover()
msgbody = tagRemover.removeTag(tmpbody)

if (objectkey==''):
    strstart = "[["
    strend = "]]"
    startpos = subject.find(strstart) + len(strstart)
    endpos = subject.find(strend, startpos)
    ticketid = subject[startpos:endpos]
    mbo.setValue("OBJECTKEY", ticketid)
else:
    ticketid = objectkey

if (strclass==''):
    strclass="INCIDENT"

strkey = "WORKLOG_DESCRIPTION="
worklogldesc = ''
inpos = msgbody.find(strkey)
if (int(inpos) > 0):
    strnewline = ";"
    startpos = msgbody.find(strkey) + len(strkey)
    endpos = msgbody.find(strnewline, startpos)
    worklogldesc = msgbody[startpos:endpos]

strkey = "WONUM="
wonum = ''
inpos = msgbody.find(strkey)
if (int(inpos) > 0):
    strnewline = ";"
    startpos = msgbody.find(strkey) + len(strkey)
    endpos = msgbody.find(strnewline, startpos)
    wonum = msgbody[startpos:endpos]

strkey = "WO_DESCRIPTION="
wodesc = ''
inpos = msgbody.find(strkey)
if (int(inpos) > 0):
    strnewline = ";"
    startpos = msgbody.find(strkey) + len(strkey)
    endpos = msgbody.find(strnewline, startpos)
    wodesc = msgbody[startpos:endpos]

#Change Activity Status
strkey = "ACTIVITY_COMPLETED="
activitystatus = ''
inpos = msgbody.find(strkey)
if (int(inpos) > 0):
    strnewline = ";"
    startpos = msgbody.find(strkey) + len(strkey)
    endpos = int(startpos) + 1
    activitystatus = msgbody[startpos:endpos]

if (wonum <> ''):
    tmp = "E-mail Update from activity #" + wonum + " (" + wodesc + ")"
    worklogdesc = tmp[:100]
    sqlf = SqlFormat("ticketid=:1")
    sqlf.setObject(1, "INCIDENT", "TICKETID", ticketid)
    incidentSet = mbo.getMboSet("$incident", "INCIDENT", sqlf.format())
    incidentMbo = incidentSet.getMbo(0)

    if (incidentMbo is not None):
        worklogSet = incidentMbo.getMboSet("WORKLOG")
        worklogMbo = worklogSet.add()
        worklogMbo.setValue("DESCRIPTION", worklogdesc)
        worklogMbo.setValue("DESCRIPTION_LONGDESCRIPTION", worklogldesc)
   
    #Change Activity Status
    sqlf2 = SqlFormat("wonum=:1 and origrecordid=:2")
    sqlf2.setObject(1, "WOACTIVITY", "WONUM", wonum)
    sqlf2.setObject(2, "INCIDENT", "TICKETID", ticketid)
    activitySet = mbo.getMboSet("$woactivity", "WOACTIVITY", sqlf2.format())
    activityMbo = activitySet.getMbo(0)

    if (activityMbo is not None):
        mxServer = MXServer.getMXServer()
        statusmemo = "EMAILUPDATE"
        current_actstatus = activityMbo.getString("STATUS")
        if (str(activitystatus) <> '1' and current_actstatus <> 'INPRG' and current_actstatus <> 'COMP' and current_actstatus <> 'CLOSE'):
            activityMbo.changeStatus("INPRG", mxServer.getDate(), statusmemo)
        elif (str(activitystatus) == '1' and current_actstatus <> 'COMP' and current_actstatus <> 'CLOSE'):
            if (current_actstatus <> 'INPRG'):
                activityMbo.changeStatus("INPRG", mxServer.getDate(), statusmemo)
            activityMbo.changeStatus("COMP", mxServer.getDate(), statusmemo)

#print "Mark Complete"
attrarray = ["status"]
keyarray = ["COMPLETE"]
newmbo = LSNRUtil.updateInboundComm(attrarray, keyarray, mbo)

print "INC_MFMAIL_ADDWORKLOG - END"
 

Incident Activity Reassign Notification

Incident Activity Reassign Notification

Create Object launch point with below Object Event Condition and Script Code.

Object Event Condition:

origrecordclass='INCIDENT' and status in ('WAPPR','QUEUED','INPRG') and (:$old_owner <> :owner or :$old_ownergroup <> :ownergroup)

Script Code:

from psdi.server import MXServer
from psdi.mbo import SqlFormat

print "INCACTREASSIGN - BEGIN"

#print "Set Status to Queued"
strstatus = mbo.getString("STATUS")
if (strstatus <> 'QUEUED'):
    mxServer = MXServer.getMXServer()
    mbo.changeStatus("QUEUED", mxServer.getDate(), "")

#pring "Check Owner or Owner Group"
strowner = mbo.getString("OWNER")
strownergroup = mbo.getString("OWNERGROUP")

if (strowner <> '' or strownergroup <> ''):
    #print "Send Email Notification"
    sqlf = SqlFormat("templateid='INCLVL2ASSIGN' and objectname='WOACTIVITY' and status='ACTIVE'")
    commTemplateSet = mbo.getMboSet("$commtemplate", "COMMTEMPLATE", sqlf.format())
    commTemplateMbo = commTemplateSet.getMbo(0)
    if commTemplateMbo is not None:
        commLogMbo = mbo.createComm()
        commLogMbo.copyFromTemplate(commTemplateMbo)
        commLogMbo.sendMessage()
else:
    errorgroup="ACTIVITY"
    errorkey="NOASSIGNMENT"
#print "End Send Notification"

print "INCACTREASSIGN - END"

Capturing the Hostname on a Ticket

Capturing the Hostname on a Ticket

You can configure the SmartCloud Control Desk to automatically store the hostname/IP of a user's workstation (client machine or machine connection to SmartCloud Control Desk) in a ticket (Service Request, Incident or Problem) when the ticket is created by following these steps.

1. Add new field to TICKET named CREATEDBYHOST
2. Set the default value of CREATEDBYHOST to 127.0.0.1
3. Create a relationship named 'CREATEDBY' on object SR (of INCIDENT, PROBLEM) with                child object: PERSON where clause: personid=:createdby)
4. Create a crossover domain named SESSION2TKT on object MAXSESSION
        from field CLIENTHOST to field CREATEDBYHOST and
       validation where clause:userid=:CREATEDBY.USER.MAXSESSION.userid
       list where clause:userid=:CREATEDBY.USER.MAXSESSION.userid
5. Associate the SESSION2TKT domain with CREATEDBYHOST
6. Save all changes and run configdb

In order to capture the hostname of the user's workstation (client machine) and not just the IP address, your web server must be configured to perform reverse DNS lookups.

To enable reverse DNS lookups in the IBM HTTP Server do the following:

1. Edit the httpd.conf file (located in Program Files\IBM\HTTPServer\conf\httpd.conf on Windows
2. Find the line that says: HostnameLookups off
3. Change the line to say: HostnameLookups on
4. Save the file and restart the web server

Incident Update SLA

Incident Update SLA

print "INCUPDATESLA - BEGIN"

#Get New SLA
#mbo.getThisMboSet().save()
slaSet = mbo.getMboSet("$serviceagreement_SLA", "SLA", "")
result = slaSet.apply(mbo)

print "INCUPDATESLA - END"

Solution Published Notification

Solution Published Notification

Create Object Launch Point on Solution Object with below Object Event Condition and Script.

Update:1
Object Event Condition: status='ACTIVE' and :$old_status <> :status

Automation Script:

from psdi.mbo import SqlFormat

print "SOLPUBNOTIFY - BEGIN"

#print "Send Email Notification"
sqlf = SqlFormat("templateid='SOLPUBL' and objectname='SOLUTION' and status='ACTIVE'")
commTemplateSet = mbo.getMboSet("$commtemplate", "COMMTEMPLATE", sqlf.format())
commTemplateMbo = commTemplateSet.getMbo(0)

if commTemplateMbo is not None:
    commLogMbo = mbo.createComm()
    commLogMbo.copyFromTemplate(commTemplateMbo)
    commLogMbo.sendMessage()

#print "End Send Notification"

print "SOLPUBNOTIFY – END"

Automation Script- Find 16 Digit numbers from long description


Find 16 Digit numbers from long description

Set the escalation to read the script. The script takes input from Long Description of SR, find the 16 digit numbers from that string with mentioned pattern and then set that numbers to summary(in SR application).


1. Created Script with Action Launch Point having two variables (IN, OUT).

      
 
 
Script Code
--------------
# Find 16 Digit numbers from Long Description and Set all 16 Digit Numbers in Summary
from java.lang import Runtime
from java.util.regex import Matcher
from java.util.regex import Pattern
descript=''
longdesc1=''
# Find the patterns of 16 Digit numbers from String and Set that 16 digit numbers into summary

pp1 = Pattern.compile("((\d{4})-(\d{4})-(\d{4})-(\d{4}))|((\d{4}) (\d{4}) (\d{4}) (\d{4}))|(\\b\\d{16}\\b)" )
m1= pp1.matcher(longdesc)
while(m1.find()):
 longdesc1=longdesc1+" "+m1.group()
descript=longdesc1
 
1   2. Created Escalation 1038 with SEPARATE action.










 Validation

Before script triggering (SR Number: 1142)

 
After Script triggering:
Script triggered through escalation. The Summary field set the with 16 digit Numbers.