IBM M A S Q R (1.1) : Aximo Utomation Cripts Uick Eference
IBM M A S Q R (1.1) : Aximo Utomation Cripts Uick Eference
1) 1
▪ app - name of the application that the script is running against. Set attribute value
▪ errorgroup/errorkey/params . Used to raise an error (see examples).
mbo.setValue("DESCRIPTION", "New description")
▪ interactive - Indicates whether the script is running in an active user session or a non-user mbo.setValueNull("DESCRIPTION")
background session, such as integration transaction processing.
▪ mbo - the MBO that is being worked on. Set attribute value with modifiers
▪ mboname - the name of the current MBO in the context of the script that is running.
▪ mbovalue - instance of the MBO attribute (attribute launch point only). from psdi.mbo import MboConstants
mbo.setValue("DESCRIPTION", "New description", MboConstants.NOACCESSCHECK)
▪ onadd/ondelete/onupdate - indicates whether the business object that the script is running mbo.setValue("DESCRIPTION", "New description", MboConstants.NOVALIDATION)
against is being inserted/created/deleted/updated. mbo.setValue("DESCRIPTION", "New description", MboConstants.NOACTION)
▪ user - the userid of the user who is logged in. mbo.setValue("DESCRIPTION", "New description", MboConstants.NOVALIDATION_AND_NOACTION)
▪ userinfo - reference to UserInfo for the current context.
▪ service - utility class with useful methods. Set field metadata (required, read-only)
Examples below. Full list of implicit variables here. from psdi.mbo import MboConstants
mbo.setFieldFlag("FROMSTORELOC", MboConstants.READONLY, False)
mbo.setFieldFlag("FROMSTORELOC", MboConstants.REQUIRED, True)
G ET A TTRI BUTES
if mbo.getString("STATUS") == 'APPR':
Count records in an MboSet
Check if attribute is null count = mbo.getMboSet("WORKORDER").count()
Copyright © 2019 Bruno Portaluri (MaximoDev) - Download the latest version of the guide: https://bportaluri.com/automation-scripts-quick-reference
IBM M AXIMO A UTOMATION S CRIPTS Q UICK R EFERENCE (1.1) 2
if interactive == True:
R AISE E RROR # Things to do if script is running in user Context
else:
Setting errorgroup/errorkey (Maximo 7.5) # Things to do if script is called by Crontask, MIF, ...
params = [mbo.getString("ASSETNUM")]
errorgroup = "msggroup"
errorkey = "msg"
R EADING S YSTEM P ROPERTY
With service object (Maximo 7.6)
from psdi.server import MXServer
params = [mbo.getString("ASSETNUM")] configData = MXServer.getMXServer().getConfig()
service.error("msggroup", "msg", params) maxProperty = configData.getProperty("mail.smtp.host")
Y ES /N O /C ANCEL S AVING M BO S ET
def yes(): Calling MboSet.save() method is not required when using relationships
# handle Yes button press
def no(): woSet = mbo.getMboSet("WORKORDER")
# handle No button press wo = woSet.getMbo(0)
def dflt(): wo.setValue("DESCRIPTION", "New")
# display the initial message woSet.save() # this is not required!
service.yncerror("msggroup", "msg")
cases = {service.YNC_NULL:dflt, service.YNC_YES:yes, service.YNC_NO:no} The MxServer.getMboSet breaks the transaction so save() is required
if interactive:
woSet = MXServer.getMXServer().getMboSet("WORKORDER", mbo.getUserInfo())
# service yncuserinput method to trigger the interaction
woSet.setWhere("WONUM='1000'")
x = service.yncuserinput()
wo = woSet.getMbo(0)
# process user input using case statement
mbo.setValue("DESCRIPTION", "New Test Asset!")
cases[x]()
woSet.save()
Copyright © 2019 Bruno Portaluri (MaximoDev) - Download the latest version of the guide: https://bportaluri.com/automation-scripts-quick-reference