This post is an excerpt from the Maximo 76 Scripting Features guide.
It’s a common thing to conditionally set some defaults when a new mbo gets added. We have so far leveraged the Object Launchpoint Init event to do that. We would need to check for onadd flag there to make sure we are adding a new mbo and then set the attribute values.
Another way to do that would be to create a script named .ADD. This will automatically add the script to the “add” callback right after the mbo add method execution has happened and right before the init() method gets called. You can use this script to now set default values conditionally. A sample script – ASSET.ADD shows how to default installdate attribute to current date only when the asset type is PUMP.
from psdi.server import MXServer
if mbo.isNull("assettype") == False and mbo.getString("assettype") == "PUMP":
mbo.setValue("installdate", MXServer.getMXServer().getDate())
Hi,
great guide. I would add that same goes for .SAVE script name
For example, Script named ASSET.SAVE will trigger on every Asset save.
Best regards,
Denis