Maximo 7.6.1.1:
我想通过在单独的系统中调用URL来运行Maximo自动化脚本。
可以这样做吗?
这是一个很好的用例,最近几天我们一直在努力。
像编写常规自动化脚本一样编写脚本。这是一个可以从URL读取一些参数并使用它们在核心系统中执行操作的参数。
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);
这里是Kasey答案的扩展版本。
在Maximo中创建示例自动化脚本:
load("nashorn:mozilla_compat.js"); //More info about this here: https://stackoverflow.com/questions/57537142/maximo-js-automation-script-importpackage-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);
尝试URL:
此URL将把单词“ Hello”发送到自动化脚本。自动化脚本将附加单词“ World!”。转到“你好”。
这句话,“世界你好!”返回。
yourhostname
1234
maximo
。URL请求应将此JSON对象返回给浏览器:
{"var1":" Hello World!"}
从那里,在单独的系统中创建超链接(使用上面的URL)。然后单击它以运行自动化脚本。
注意:
URL在WILSON用户下似乎只对我有用。它不适用于我自己的用户:
{"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"}}}}
最好的猜测是:我的用户设置不正确。