top of page

Maximo – Automation scripts

I’ve started to be working on the Maximo project. Anyway, I’ve found and customized few automation scripts in Jython that are checking user’s input in Self Service Center offerings (in my case) but can be placed almost in every field. 

IP validation

# separated by dots (.)
#valid number between 0 255
errmsg = ''
rc = 1
ipList = newValue.split('.')
if len(ipList) == 4:
   for i in ipList:
         i = int(i)
         rc = 0
         errmsg = i, ' is not a valid number. IP Addresses must contain valid numbers'
      if i > 255:
         rc = 0
         errmsg = i, ' is greater than 255. Valid IP Addresses are between 0 and 255.'
   rc = 0
   errmsg = 'IP Addresses must be in the form nn.nn.nn.nn'
print rc
print errmsg

Ensure the end date is after the start date

Check that the end date comes after the start date from java.text import SimpleDateFormat

fmt = SimpleDateFormat('MM/dd/yyyy')
rc = 1
errmsg = ''
# get the fields
startdatestr = offeringAttributes.getValue("STARTDATE");
enddatestr = offeringAttributes.getValue("ENDDATE");
# if both have values, format them, and ensure the enddate is after the start date
if len(startdatestr) > 0 and len(enddatestr) > 0: 
startdate = fmt.parse(startdatestr)
enddate = fmt.parse(enddatestr)
if enddate.before(startdate):
rc = 0
errmsg = 'End Date must be greater than Start Date'
print rc
print errmsg

Create a string and set the value of one field, based on the value of another

Build and set the value of the server field based on the hostname field

property= offeringAttributes.getValue("HOSTNAME");
dhostname = newValue+'.'+property+''offeringAttributes.setNewValue("SERVER",server);
print True

Check if the entered value is a valid number

# make sure the value specified is all valid digits
rc = True
errmsg = ''
if newValue.isdigit() == False:
 rc = False
 errmsg = 'Value must be numeric'
print rc
print errmsg


Commenting has been turned off.
bottom of page