1

I have some relatively simple code which displays a yes/no dialog in Maximo 7.6.0.9. Porting to Maximo 7.6.1.1 did not work at all despite using the compatibility option. No dialog is displayed and the debug is indicating it doesn't know what the constants for yes and no are which leads me to believe that I didn't specify the service package correctly but it is not clear to me how to make this work.

The code while working under Maximo 7.6.0.9 and WebSphere 8.5.5.4, fails under: Maximo IBM Maximo Asset Management 7.6.1.1 Build 20190514-1348 DB Build V7611-01, websphere 9.0.5.1

Here is the basic automation script:

load("nashorn:mozilla_compat.js");

importClass(Packages.psdi.mbo.MboRemote);

importClass(Packages.psdi.mbo.MboConstants);

importClass(Packages.psdi.mbo.MboSetRemote);

importClass(Packages.com.ibm.tivoli.maximo.script.ScriptService);

importClass(Packages.psdi.util.MXApplicationException);

importClass(Packages.psdi.server.MXServer);

importClass(Packages.psdi.iface.mic.InvokeChannelCache);

importClass(Packages.psdi.mbo.GLFormat);





var attTest = processAnyAttachments(mbo);







function queryuser(mbo) {

    service.log(scriptName + ".JS - entering queryuser(mbo)");

    service.log(scriptName + ".JS - service.YNC_NULL = " + service.YNC_NULL +

    ", service.YNC_NO = " + service.YNC_NO + ", service.YNC_YES = " + service.YNC_YES);

    service.log(scriptName + ".JS - service = " + service);

    var answer = service.yncuserinput();

    if (answer == service.YNC_NULL) {

        service.yncerror("slcfinance", "nopoattachments");

    } else {

        service.log(scriptName + ".JS - answer != service.YNC_NULL, but: " + answer);

    }

    if (answer == service.YNC_NO) {

        service.log(scriptName + ".JS - answer == service.YNC_NO");

        service.error("slcfinance", "usercancel");

    } else {

        service.log(scriptName + ".JS - answer != service.YNC_NO, but: " + answer);

    }

    service.log(scriptName + ".JS - leaving queryuser(mbo)");

}



function processAnyAttachments(mbo) {

    service.log(scriptName + ".JS - entering processAnyAttachments(mbo)");

    var retVal = true;



    var doclinksMSR = mbo.getMboSet("DOCLINKS");

    if ((doclinksMSR != null) && (!doclinksMSR.isEmpty())) {

        service.log(scriptName + ".JS - some doclinks found");

    } else {

        service.log(scriptName + ".JS - no doclinks found");

        if (interactive) {

            service.log(scriptName + ".JS - invoking queruser(mbo)");

            retVal = queryuser(mbo);//TBD MAKE THIS WORK

            service.log(scriptName + ".JS - Done invoking queruser(mbo)");

        }

    }

    service.log(scriptName + ".JS - leaving processAnyAttachments(mbo) - retVal = " + retVal);

    return retVal;

}

I tried with the ync message of type "i" and "e" just in case it was something there with no change.

Can someone tell me how to make this work? Otherwise I"ll have to switch to jython which is a fair amount of labor. thanks

ok I'm not sure if I made a mistake or not but my output looks like this now: -- it doesn't matter if I import or don't import the serviceScript

ScriptMboEventListener Event maximo.po.update has been fired for script POBEFORESAVE launch point POBEFORESAVE
POBEFORESAVE.JS - entering processAnyAttachments(mbo)
POBEFORESAVE.JS - no doclinks found
POBEFORESAVE.JS - invoking queruser(mbo)
POBEFORESAVE.JS - entering queryuser(mbo)
POBEFORESAVE.JS - service.YNC_NULL = undefined, service.YNC_NO = undefined, service.YNC_YES = undefined
POBEFORESAVE.JS - service = com.ibm.tivoli.maximo.script.ScriptService@5db5a021
POBEFORESAVE.JS - answer != service.YNC_NULL, but: -1
POBEFORESAVE.JS - answer != service.YNC_NO, but: -1
POBEFORESAVE.JS - leaving queryuser(mbo)
POBEFORESAVE.JS - Done invoking queruser(mbo)
POBEFORESAVE.JS - leaving processAnyAttachments(mbo) - retVal = undefined  

   update 20300710- I think it is a bug in 7.6.1.1
kishjeff
  • 121
  • 13
  • I didn't think you needed to import the script service; I thought that was already implicitly given to the script. That in turn should mean it shouldn't have a problem knowing what those YNC constants are (the only hint of an error your question provides). What are you actually getting in the logs when this runs? Is there an error with a stack trace? – Dex May 14 '20 at 13:07
  • I may of made a mistake.. I'll paste the output in a repsonse. – kishjeff May 17 '20 at 16:16
  • Well that's odd. You do have a service object, but the constants of the object aren't defined? I can see them in the 7.6.1.1 code I decompiled. Can you grab the com.ibm.tivoli.maximo.script.ScriptService class out of the ear you have deployed and decompile it to make sure the contstants are in there? If not, something is wrong with your deployed ear and maybe your install. If they are in there, maybe there is some bug in the JavaScript engine that strips them out? – Dex May 18 '20 at 03:43
  • In the meantime, you can declare the constants yourself though. YNC_CANCEL = 4; YNC_NO = 16; YNC_NULL = -1; YNC_OK = 2; YNC_YES = 8 https://developer.ibm.com/static/site-id/155/maximodev/7609/maximocore/businessobjects/constant-values.html#com.ibm.tivoli.maximo.script.ScriptService.YNC_CANCEL – Dex May 18 '20 at 03:43

2 Answers2

2

I had to change all of my comparison operators (i.e. "!=" to "!==" and "==" to "===")

dwohlrs
  • 33
  • 4
1

I submitted a case to IBM. It seems this broke with Nashorn. They sent me a new jar to use, and I also had to take @Dex's advise and declare the constants as they were no longer visible.

kishjeff
  • 121
  • 13