Checking if an Attribute Exists or Not on an Object via Automation Scripts

August 22, 2017 Yalcin Kumbasar

If you need to check that an attribute (field) exists on an object (MBO) or not, then you may use the following python code pieces in your Automation Scripts:


Alternative 1:

mboValueData = mbo.getMboValueData(['ATTRIBUTENAME'])
if mboValueData[0] is not None:
    mbo.setValue("ATTRIBUTENAME", "NEWVALUE")


Alternative 2:

from import UserInfo
from psdi.server import MXServer

mxServer = MXServer.getMXServer()
userInfo = mbo.getUserInfo()
objectName = mbo.getName()

attrSet = mxServer.getMboSet("MAXATTRIBUTE", userInfo)
attrSet.setWhere("objectname = '" + objectName + "' and attributename = 'ATTRIBUTENAME'" )

if(not attrSet.isEmpty()):
    mbo.setValue("ATTRIBUTENAME", "NEWVALUE")


PS: There are other methods in Maximo framework in order to do the same check, but they return "Attribute {0} does not exist" exception and they require error handling. So the two alternatives above are the easier options.

Previous Article
Maximo Asset Management Interim Fix 009 released - do not use

Update 31 August: Do not download. A new Maximo Asset Management Interim Fix will be released shor...

Next Article
Extracting Maximo 7.6 Packages in Red Hat Linux

Extracting Maximo 7.6 Packages in Red Hat Linux - This video demonstrates how to extract the Maximo 7.6 pac...


Want our latest news? Subscribe to our blog!

Last Name
First Name
Thank you!
Error - something went wrong!