Skip to content

Call Maximo Automation Scripts from JSON API

It was not until I read chapter 14 of IBM’s overview of the Maximo JSON API that it occurred to me that we could use the JSON API to launch an automation script in Maximo and then see the results in the return message. We can create our own APIs using the relative simplicity of an automation script and not have to write a single line of Java code. Truly powerful stuff! The example provided in the article was also useful to me in that I was going through the process of loading data into Maximo when I came across the article. The script used in the article queries Maximo objects and reports back a record count. In my situation this was a very poignant and timely revelation.

Creating the Script

The first step in this process is to create an automation script that we want Maximo to run. I took the script provided in the example and expanded the list of objects to suit my situation. Besides the additional objects I wanted a total count of records that were loaded which is the purpose of the “Get Total Count” section at the end of the script. Source Code:
// Create the response object
var resp = {};
// Get the Site ID from the Query Parameters
var site = request.getQueryParam("site");
// Count of Work Orders
var woset = MXServer.getMXServer().getMboSet("WORKORDER", request.getUserInfo());
var woCount = woset.count();
resp.wo_count = woCount;
// Count of Service Requests
var srset = MXServer.getMXServer().getMboSet("SR", request.getUserInfo());
var srCount = srset.count();
resp.sr_count = srCount;
// Count of Items
var itmset = MXServer.getMXServer().getMboSet("ITEM", request.getUserInfo());
var itmCount = itmset.count();
resp.item_count = itmCount;
// Get Total Count = woCount+srCount+itmCount;
var responseBody = JSON.stringify(resp);
Navigate to the Automation Script application and select Create and then choose Script. Since we are going to be launching this script from an HTTP call we just need to create the script and not provide a separate launch point. Fill out the script Name, Description, Language and the Source Code from above. Make sure the script is Active and select Create to save the script.

Executing the Script

We need three pieces of information to complete a successful JSON API call:
  • Site ID
    • In this example we are using the demonstration data, so our site is BEDFORD.
  • Username and Password
    • User Name: maxadmin
    • Password: maxadmin
  • URL
    • http://maximo_host/maximo/oslc/script/a3j_recordcount?_lid=maxadmin&_lpwd=maxadmin&site=BEDFORD
    • Note that there are underscores in front of lid and lpwd which might now be obvious from the link formatting above.

Script Results

"wo_count": 1331,
"sr_count": 41,
"item_count": 357,
"total": 1729

Share This

Related Posts

ibm_mxmobile_maximo mobile_app_application_suite_report_maintenance_reliability_industry_4_work_order_enterprise_asset_management_inventory_perform_count_log_time_create_meter_reading_shipping_and_recieving_mobility_admin_service_request_issue_parts_material_approve_task_job_plan_software_upgrade
MxMobile Update May 2023 Release
As an IBM Maximo mobile solution provider, A3J Group consistently improves the functionality and features...
Workflow Delegates
Pretend you are going to take a real vacation, two weeks in Spain with no work laptop. You have planned...
ibm_mxmobile_maximo mobile_app_application_suite_report_maintenance_reliability_industry_4_work_order_enterprise_asset_management_inventory_perform_count_log_time_create_meter_reading_shipping_and_recieving_mobility_admin_service_request_issue_parts_material_approve_task_job_plan_software_upgrade
MxMobile Update April 2023 Release
A3J Group is happy to announce the latest MxMobile releases below. The releases will be available on...

3 Responses


  1. Hi Bob,
    Is there a way to read the content of the JSON body in automation script?
    We can use request.getQueryParam() to read URL parameters and request.getHeaderParams() to read header.
    But is there any method to read body of JSON API in automation script?

  2. Hi Bob,
    Is it possible to read the content of the JSON body from automation script?
    request.getQueryParam() is to read query parameters and request.getHeaderParams() is to read header parameters.
    Is there any method to read body content from the JSON API?


  3. Hi Bob,
    Have you set up a script like this up in Maximo to use oAuth2 as the authentication mechanism? If so would you describe the basic steps?

Add a Comment