About this task
An automation script is configured to create multiple Incident records in Maximo IT
and adds a Communication Log entry to each of them.
Follow the steps below to create the automation script:
Procedure
-
Open the Automation Scripts application.
-
On the navigation panel, click Create and select
Script.
-
On the Create Script pop-up, fill the fields as
follows:
- Script: Specify as Jython
- Script Language: Search and select
jython
- Log level: Search and select
ERROR
- Click Next.
-
You can import the below script or paste it on the below script box, and click
Create.
Note: The below script is a sample and for reference only,
update the script as per your custom field ID's and other changes as
necessary.
from psdi.mbo import Mbo
from psdi.mbo import MboSet
from psdi.mbo import MboConstants
from psdi.mbo import MboRemote
from psdi.server import MXServer
server = MXServer.getMXServer()
#user = scriptHome.getUserInfo()
userInfo = MXServer.getMXServer().getUserInfo("MAXADMIN")
incidentSet = server.getMboSet("INCIDENT", userInfo)
#CHANGE COUNT as required, if want to create 100/1000/5000 as per requirement
initial = 34679 #can change the initial and end to whatever you want
end = 34680
for i in range(initial, end):
incidentMbo = incidentSet.add()
desc = "Computer is not working"
incidentMbo.setValue("DESCRIPTION", desc)
#incidentMbo.setValue("TICKETID", ticketId)
commLogSet = incidentMbo.getMboSet("commlog")
commLogMbo = commLogSet.add()
commLogMbo.setValue("subject", "Test Comm")
commLogMbo.setValue("message", "Test message for comm log Entry " + desc)
incidentSet.save()
print("Record Created -" +desc)
-
Save your changes.