Skip to main content

Digital Experience

Maximo Automation Scripting – Keep it Simple

Recently I was tasked with making one of 3 fields mandatory on a Maximo application. Doesn’t sound like rocket science, and in the past, my first thought would have been to work out a fun and complicated set of Conditional Expressions. Then I got to thinking, wouldn’t it be easier to just do an If-then statement somehow? Surely this automation scripting stuff can’t be as difficult as everyone always tries to make it. Well, I found out it’s not, and its amazingly powerful in a short amount of time.

The Assignment

What are the conditions that are needing to be met? We needed to make sure that before a WO was saved, either the Supervisor, Crew, or Owner was populated. The client will be using this information for reporting and Start Center portlets, so it was important to have the information on every Work Order.

Starting an Automation Script

As I am not now, nor have I ever been an automation scripting guru, I always have to play around in Dev environments to get the kinks worked out. I’ve been modifying others scripts for years but writing them from scratch was never my forte. No better time than the present to pick up the torch and run! I know enough to be dangerous, which is why I surround myself with some of the brightest people I know to help me out in a jam.

Maximo Automation Scripting

To get started I chose an Object Launch point. I figured it was a good choice as I’m working with Workorder object and not just on specific attribute. And to keep things simple, I usually name my launch point and the Automation script the same thing. Simple name for this one was SUPERCREWOWNER_OR.

I used some variables to make it easier to pull info in and pass it back out. To clean it up, they could all be just inbound, but it defaults to INOUT, so I just left it. I’m not passing any values back to the variables in my simple code.
Automation Script Launch Point Variables

The Code – Keep it Simple

Up front I will tell you, I am not a jython expert. Most all I have learned I have done so like many other coders, I have google the snot out of it until I found something close and made it work! This was no exception. I also leaned on some of my co-workers knowledge to make it as simple as I could. Instead of using OR logic though, it was easier to use NOT logic, as you will see in the code. The first requirement is that the Workorder has a Workorder number, then we move forward from there.

if wo is not None and (super is None and crew is None and owner is None):
..errorgroup='Custom'
..errorkey='superORcrewORowner'
..params=[wo]

The leading periods are to show mandatory spacing.

Essentially, if WONUM is NOT blank (required to save a WO), and all three of the other fields ARE blank, a custom error is thrown.

Note: To make the error work, you need to configure your custom error message. I will cover that in another post.

Once one of the fields is populated, the Work Order saves with no further interference.

Simple is Good

And that’s it! A simple automation script that throws an error and stops you from saving the record unless one of 3 fields are populated. Can Automation scripts be insanely more complicated? Yes, they can. Is it really necessary in all cases? Nope. This shows an easy solution to what could be an overly complicated set of multiple other tasks.

If you enjoyed this post, check out some of my other posts.

If you have any comments or questions, please leave a comment below!

Tags

Thoughts on “Maximo Automation Scripting – Keep it Simple”

  1. i do the same with you, but i get 2 attribute (sub from table a and part from table b with relationship from a) from 2 table. When I input a and save. it’s have a message like you and input the other => ok.
    But when I input two object in 1 time and SAVE, it’s still error message. Can you help me to solve it? Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Chad Stringer, Lead Technical Consultant

I have 18 years of Maximo experience from installations, upgrades, data loading, process improvement consultation, and all around system usage. I have over 20 years of experience in the IT industry including data ETL, warehousing, process control systems, system administration, and much more.

More from this Author

Follow Us