About cookies on this site Our websites require some cookies to function properly (required). In addition, other cookies may be used with your consent to analyze site usage, improve the user experience and for advertising. For more information, please review your options. By visiting our website, you agree to our processing of information as described in IBM’sprivacy statement. To provide a smooth navigation, your cookie preferences will be shared across the IBM web domains listed here.
Technical Blog Post
Abstract
Checking if an Attribute Exists or Not on an Object via Automation Scripts
Body
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 psdi.security import UserInfo from psdi.server import MXServer mxServer = MXServer.getMXServer() userInfo = mbo.getUserInfo() objectName = mbo.getName() attrSet = mxServer.getMboSet("MAXATTRIBUTE", userInfo) attrSet.reset() 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.
[{"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SSLKT6","label":"IBM Maximo Asset Management"},"Component":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"","Edition":"","Line of Business":{"code":"LOB59","label":"Sustainability Software"}}]
UID
ibm11129677