One of the frustrations I always have with Maximo is knowing something I want to do can be done, but not having the technical skills to cross the finish line. Automation Scripting continues to be in that category for me. This week I was asked by a couple of users if there was a way to clear out certain fields when a record is duplicated. We had the philosophical debate on "duplicate" vs "new". They presented a good case that if the fields they asked to get cleared could happen it would make their time in Maximo more effective.
What was being asked is when an Asset record is duplicated, the following should occur:
- The DESCRIPTION field should be cleared of the previous record's text.
- The SERIALNUM field should be cleared of the previous record's text.
- The
CUSTOM
fields should be cleared of the previous record's text.
My immediate thought was this should be able to be handled by an Automation Script. So I did what every Maximo administrator does now... I went to Google.
Maximo automation script clear duplicate record values
The 3rd result led me back to a trusted source - Bruno Portaluri's (@bportaluri) blog on Maximo. The post that Google found was almost what I was looking.1 Bruno had done a great job explaining some new functionality in Automation Scripting when a Maximo record was modified under 3 different conditions:
- When a record is created (NEW)
- When a record is saved (SAVED)
- When a record is duplicated (DUPLICATE)
Those record events could trigger an Automation Script to take scripted actions on the record. I didn't see a good working example in Bruno's blog post, so I continued looking around.2 After some further reading, and more than a few dead ends, I went back to Bruno's post to see what other hints I could pick up. After reading his blog post for the 5th time I finally saw what I missed...
Open the Automation Scripts application and select Create > Script from the action menu.
Now it clicked on what I needed to do.
Visual example of ASSET.DUPLICATE script
Just like Bruno's script example, I needed to create an Automation Script to change the values of fields when a record was duplicated. So I did as he instructed and created a new Script.
Maximo will open a new Script dialog box with just the basic requirements.
The upside to this focused version is you do not have to worry about the launch attributes like an Object or Attribute script. You literally just need to add the script details.
From what I read in Bruno's post and a couple of other blog posts, there is a built in understanding of the MBO object dupmbo
used in the script. So to clear the value of the ASSET.DESCRIPTION field, all I needed to call was this MBO for Maximo to automagically know it should take action on the duplicate record.
Small tweaks make a big difference
Normally to set a value in an Automation Script you would use the syntax of
mbo.setValue("DESCRIPTION", "Set New Text")
In my case I needed to set the values of the fields to NULL
instead of a set value. So I attempted to set the value NULL
or NONE
, while using the dupmbo
:
dupmbo.setValue("DESCRIPTION", None)
That didn't work. Doing some more research I found a snippet on a blog post on how to set the value of a field to a blank value.
mbo.setValueNull("DESCRIPTION",11L);
So now I could use the reference to dupmbo
and set the value of a field to a blank.
dupmbo.setValueNull("DESCRIPTION",11L);
The whole script looks like this:
Once the script was saved I could open an Asset record and see the current values:
And after duplicating the record, the key fields are now blank:
Done.
Shout out to Bruno and Stephen Hume on the information they've shared with the Maximo community.