Maximo 7.6.1.1:
I want to run a Maximo automation script by invoking a URL in a separate system.
Is it possible to do this?
Maximo 7.6.1.1:
I want to run a Maximo automation script by invoking a URL in a separate system.
Is it possible to do this?
This is a great use-case and something that we've been working through in the last few days.
Script it like you would your regular automation script. Here's one that can read in a few parameters from the URL and use those to perform operations in the core system.
importPackage(Packages.psdi.server);
importPackage(Packages.psdi.util.logging);
var resp = {};
// Get the Site ID from the Query Parameters
//var site = request.getQueryParam("site");
var var1 = request.getQueryParam("var1");
var var2 = request.getQueryParam("var2");
var site = request.getQueryParam("site");
//var zxqponum = request.getQueryParam("ponum");
//logger.debug(zxqprinter);
service.log("TESTING script Params" + request.getQueryParams());
service.log("var1 " + request.getQueryParam("var1"));
service.log("var2 " + request.getQueryParam("var2"));
//count the number of WO's in the site
var woset = MXServer.getMXServer().getMboSet("WORKORDER", request.getUserInfo());
woset.setQbe("SITEID","="+site);
var woCount = woset.count();
resp.wo_count = woCount;
woset.close();
// Get Total Count
resp.total = woCount;
//create the response - still not sure why I had to append the vars to a string.
resp.var1= "" + var1;
resp.var2= "" + var2;
resp.site= "" + site;
var responseBody = JSON.stringify(resp);
request.getQueryParam()
may return a byte[]
not a Javascript string. –
Theotokos Here's an expanded version of Kasey's answer.
Create a sample automation script in Maximo:
//THIS IS JAVASCRIPT! NOT JYTHON!
//load("nashorn:mozilla_compat.js"); //More info about this here: https://mcmap.net/q/2036154/-maximo-js-automation-script-quot-importpackage-quot-is-not-defined
//importPackage(Packages.psdi.server);
//importPackage(Packages.psdi.util.logging);
var resp = {};
var var1 = request.getQueryParam("var1");
resp.var1= " " + var1 + " World!";
var responseBody = JSON.stringify(resp);
Try out a URL:
This URL will send the word "Hello" to the automation script. The automation script will append the word " World!" onto "Hello".
The phrase, "Hello World!" is returned.
yourhostname
with your host name1234
with your port numbermaximo
with the appropriate value.{"var1":" Hello World!"}
Note:
The URL only seems to work for me under the WILSON user. It doesn't work with my own user:
{"oslc:Error":{"oslc:statusCode":"401","spi:reasonCode":"BMXAA7901E","oslc:message":
"You cannot log in at this time. Contact the system administrator.","oslc:extendedError"
:{"oslc:moreInfo":{"rdf:resource":"http:\/\/something\/maximo\/oslc\
/error\/messages\/BMXAA7901E"}}}}
Best guess is: my user is not set up correctly.
Here's a really simple JavaScript example:
responseBody = "asdf";
Then just run the URL in a browser (or somewhere else like an automation script in Maximo or a Python script in GIS).
https://<<my host>>/maximo/oslc/script/testscript
It's pretty much the same for Python (no semi-colon):
responseBody = "asdf"
© 2022 - 2024 — McMap. All rights reserved.