Maximo

Maximo

Come for answers, stay for best practices. All we're missing is you.

 View Only
  • 1.  Maximo 7.6.1 - Automation script. Errors with parameters doesnt work (javascript)

    Posted Thu May 28, 2020 09:40 AM

    Hello everyone,

    We recently upgraded to Maximo 7.6.1 from Maximo 7.6.0 and there is a problem with our automations scripts that show errors with parameters, they are not taking the values as parameters as they did with Maximo version 7.6.0.

    The syntax is as follows:

    errorgroup = "workorder";
    errorkey = "newerror";
    params = [value1, value2];

    Message in the dabatase configuration is as follows:

    "Error message example with value 1 {0} and value 2 {1}".

    Since the upgrade to Maximo 7.6.1, every error message with parameter is just showing the message without replacing the values. Code is written in javascript.

    Any advice will be helpful.

    PD: English is not my main language, sorry for the grammar.



    ------------------------------
    Arturo Carmona Lozano
    ------------------------------

    #Maximo
    #AssetandFacilitiesManagement


  • 2.  RE: Maximo 7.6.1 - Automation script. Errors with parameters doesnt work (javascript)

    Posted Fri May 29, 2020 02:39 AM
    Hi Arturo,

    First of all - Interesting name for me as I just watched Money Heist! :)

    Coming back to your question: I think it is happening because Maximo changed the javascript engine in 7.6.1. 
    Here below is an useful post that provides resolution to that issue.It talks about how to handle the java script engine change issue:
    https://a3jgroup.com/automation-scripts-compatibility-with-maximo-7-6-1/

    Other issue could be the related to the use of  param value in java script. 
    Here below is a nice explanation and resolution for that issue:
    https://a3jgroup.com/automation-scripts-compatibility-with-maximo-7-6-1/

    Hopefully this will help!

    Thanks,
    Biplab

    ------------------------------
    Biplab Choudhury
    Maximo Consultant
    Tata Consultancy Services
    Melbourne
    ------------------------------



  • 3.  RE: Maximo 7.6.1 - Automation script. Errors with parameters doesnt work (javascript)

    Posted Fri May 29, 2020 12:06 PM
    Edited by System Admin Wed March 22, 2023 11:47 AM
    Hi Biplap,

    Thanks for the answer!

    The following line load("nashorn:mozilla_compat.js"); helped me to fix some problems with javascript automation scripts.

    Best regards,
    Arturo Carmona


    ------------------------------
    Arturo Carmona Lozano
    ------------------------------



  • 4.  RE: Maximo 7.6.1 - Automation script. Errors with parameters doesnt work (javascript)

    Posted Fri May 29, 2020 03:04 AM
    Hi Arturo,

    Maximo V7.6.1 has upgraded its Java version to 8. It has changed the default JavaScript engine named Nashorn that Oracle's in-house JavaScript implementation of script engines, instead of previously provided script engine - Rhino created by Mozilla. Your script may fail to run on the new script engine because there are several differences between the engines.

    Please find the snippet that the fixed version of your script worked in my environment.
    errorgroup = "workorder";
    errorkey = "newerror";
    params = new java.util.ArrayList();
    params.add("P1");
    params.add("P2");
    Thanks.
    • Add to Phrasebook
      • No word lists for English -> Japanese...
      • Create a new word list...
    • Copy


    ------------------------------
    YASUTAKA NISHIMURA
    ------------------------------



  • 5.  RE: Maximo 7.6.1 - Automation script. Errors with parameters doesnt work (javascript)

    Posted Fri May 29, 2020 12:09 PM
    Hi Yasutaka,

    Thanks for the answer!

    Your code helped me to solve my problem with error messages with parameters, i tested it with my own scripts and it works as it was with Maximo version 7.6.0.9. You are a life saver.

    Best regards,
    Arturo Carmona

    ------------------------------
    Arturo Carmona Lozano
    ------------------------------



  • 6.  RE: Maximo 7.6.1 - Automation script. Errors with parameters doesnt work (javascript)

    Posted Fri May 29, 2020 08:54 AM
    I haven't had a problem using jython lists as before instead of java.ArrayList; the first thing I'd try is adding double quotes around the values in your list, i.e. ["value1", "value2"]

    If that doesn't help, here's an article about using the mozilla-compatible version of Nashorn:
    https://a3jgroup.com/automation-scripts-compatibility-with-maximo-7-6-1/

    ------------------------------
    Robert Goff
    ------------------------------



  • 7.  RE: Maximo 7.6.1 - Automation script. Errors with parameters doesnt work (javascript)

    Posted Fri May 29, 2020 01:23 PM
    To import classes properly in Nashorn you can do the following, where you import the MXServer class and then in this case get the LABOR MboSet.

    var MXServer = Java.type("psdi.server.MXServer")
    
    var set = MXServer.getMXServer().getMboSet("LABOR", MXServer.getMXServer().getSystemUserInfo());


    You may also run into issues with calling overloaded methods such as mbo.setValue("attribute","value") since the value parameter may be of many different types.  To avoid this you can specify the specific method you want to call by specifying the types as shown below.

    mbo["setValue(String, String)"]("ATTRIBUTENAME", "string value")

    mbo["setValue(String, int)"]("ATTRIBUTENAME", "int value")


    ------------------------------
    Jason VenHuizen
    ------------------------------



  • 8.  RE: Maximo 7.6.1 - Automation script. Errors with parameters doesnt work (javascript)

    Posted Wed June 03, 2020 03:55 PM
    Hello all,

    Another option is to use the global implicit "service" variable as follows:
    service.error("workorder","newerror",[val1,val2...])
     
    The "service" variable is an instance of com.ibm.tivoli.maximo.script.ScriptService.
     
    With this Maximo 76 approach, error processing will stop the script execution. With the Maximo 75 approach (setting the errorgroup, errorkey, and params variables), processing continues to the end of the script.
     
    If the message to be displayed is a warning instead of an error, use the following:
     
    service.setWarning("workorder","newwarning",[val1,val2...])
     
    The the global implicit "service" variable can be used with other scripting languages as well.


    ------------------------------
    Joe Gydus
    ------------------------------