Automation Script: params variable not working with JavaScript language

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:

PhoneRequired

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!

Series Navigation< How to Rollup Cost with the Automation ScriptImport Classes and Packages using Javascript Language and Automation Scripts >

Did You Know...

As Maximo Experts, we have developed Maximo adds on products to make Maximo work assignment simple, reporting easy, and facilitating service requests seamless. Check out our additional products EZPlanner, EZInsight, and EZRequest.

Find Out More

Leave a Reply

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