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
This entry is part [part not set] of 8 in the series Maximo Automation Scripts

Did You Know...

As Maximo Experts, we have developed several add-on products for Maximo that mobilize the work force, simplifies assignments, provides ad-hoc reporting capabilities and facilitates the seamless integration of Service Requests into Maximo.

Check out our products by clicking on the following links: EZMaxMobile, EZMaxPlanner and EZMaxRequest.

Find Out More

Leave a Reply