H,
there are several things to consider.
"If a variable is null (i.e. it has no value) then it can only be checked using variable is None.
If var is None:
Some string functions return an empty string so it is important to check for ""
If var = "":
If the variable isn't defined then errors like this can be generated when the script tries to use a variable which is set to null."
This is an extract from the Vetasi automation script training course.
The IBM Javadocs for the MBO set shows that there is a method to check if an attribute is null:
"
|
isNull(java.lang.String attributeName)
Determines whether the attribute value identified by name within the current object is null.
|
"
It IS possible to explicitly set a value to an empty string in an ORACLE column.
A common mistake is to assume that "" is null.
I hope this helps.
------------------------------
Mark Robbins
Support Lead/Technical Design Authority / IBM Champion 2017 & 2018 & 2019 & 2020 & 2021
Vetasi Limited
https://www.linkedin.com/pulse/maximo-support-advice-from-non-ibm-engineer-article-mark-robbins/------------------------------
Original Message:
Sent: Tue November 09, 2021 04:34 PM
From: User1971
Subject: Clean Jython: If field is null
MAM 7.6.1.2, Jython, Oracle 19c:
I have a Jython automation script that checks to see if CLASSSTRUCTURE.DESCRIPTION is null:
if not mbo.getString("DESCRIPTION"):
mbo.setValue("DESCRIPTION", mbo.getString("CLASSIFICATIONDESC"))
As a novice, I find if not mbo.getString("DESCRIPTION"):
to be unintuitive to read.
I'd rather use something like if mbo.isNull("DESCRIPTION"):
. I find that easier to read.
Question:
What is a good/intuitive way to check for nulls via Jython? Do I need to worry about empty strings? (note: I don't think empty strings exist in Oracle tables)
#AssetandFacilitiesManagement
#Maximo