Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run an automation script via a URL

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?

like image 557
User1974 Avatar asked Oct 17 '19 17:10

User1974


1 Answers

This is a great use-case and something that we've been working through in the last few days.

  1. Create automation script. - mine is called automation_api_test
  2. Manually invoke it through the API using a browser to make sure that you can actually get it to run. (%servername%/maximo/oslc/script/automation_api_test?var1=1212321232&var2=1555&site=OPS&_lid=wilson&_lpwd=wilson)
  3. 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);
    
like image 90
Kasey Avatar answered Sep 27 '22 21:09

Kasey