- A Collection of Maximo Automation Script Examples
- Prevent completion / closure of work orders with open labor transactions
- Automatic Status Changes for Service Requests (SR) with Automation Script
- Import Classes and Packages using Javascript Language and Automation Scripts
- Automation Script: params variable not working with JavaScript language
- How to Rollup Cost with the Automation Script
- Disable Maximo business rule with an Automation Script
- Your first Automation Script in Maximo 7.5
With the Automation Script there is an implicit variable called “params” that is supposed to be used with the MXException error. If the error being thrown is parameterized, then this “params” variable should be used to set the parameters. For example, if the maxmessage is something like “Required Field {0} is missing”, the params should fill in the blanks, but it doesn’t work with any of the JavaScript based languages.
Here is a simple example that works in Jython:
errorgroup = "system"; errorkey = "allnullrequired"; params = ["PHONE"];
You can test this on the WORKORDER object and you should get this dialog:
This works as expected, but if you change the language type to JavaScript (as a web developer, I prefer JavaScript), the same code does not work but it should! (It may work with other maxmessages, but I haven’t tried)
Here is a work around for using the “params” with Javascript. The trick is to first instantiate the “params” variable as a new Java Array. You can make the array size whatever you need it to be, then set the array list values.
errorgroup = "system"; errorkey = "allnullrequired"; params = java.lang.reflect.Array.newInstance(java.lang.String, 1); params[0] = "PHONE";
Lesson learned, Jython probably works best for Automation Scripts… guess I need to start learning!