Category: Blog (Page 3 of 4)

Your blog category

How to export Maximo data to Excel using Automation Script?

Earlier I provided an example of how to extract and send data as CSV to a user via email. A friend asked me about a requirement he is dealing with. In this case, he has an escalation which sends an email when there is an error with integration. The problem with this approach is if there are many failed transactions, the administrator will receive a lot of emails.

The alternative approach is setting up a scheduled BIRT report which lists all errors in one file. However, this approach also has a problem. On the days when there are no failures, the admin would still receive an email and still have to open the file to see whether there is an error or not.

This is actually a common requirement. Below are some examples:

  • Operation managers like to monitor a list of critical assets. Maximo should send out a maximum of one email per day with the list of active SR and WOs when the asset is down. Do not send emails if there are no issues.
  • Operators like to receive a list of all high-priority work orders reported daily in one email, such as work orders that deal with water quality issues or sewer overflow.
  • The system admin wants to get a list of suspicious login activities daily.
  • System owners like to monitor data quality issues. Only send out a report if there are issues.

Below is an example of how we extract all P1 work orders in site BEDFORD, and save the data to an Excel file. I didn’t include the code to attach the file and send out an email as it has already been provided in my previous post

As usual, I test the script by calling it via API. Below is how the data looks when opened in Excel.

For data aggregation or when complex joins are required, we can also run an SQL query to retrieve data. Below is an example that provides a list of locations and the total number of work orders for each location.

Below is the data exported by the script

How to send email with CSV attachment using Automation Script

A client asked me to set up Maximo to automatically export work order data in CSV format and send it out via email. Initially, I suggested using the scheduled report function. We can build a simple BIRT report which has one data table. It can be scheduled to run automatically and send out an email with the data attached in Excel format. The user will simply have to open the file and save it in CSV format.

The solution was not accepted due to two reasons:

  • It involves some manual intervention.
  • BIRT Excel format has a limitation of 10,000 rows. If there are more rows, the data is split into multiple worksheets.

To address this requirement, I wrote an automation script that does two things:

  • First, it fetches the MboSet and generates the CSV content using the csv library.
  • Send an email with the CSV file attached.

Below is the simplified version as an example. It works with the OOTB Maximo demo instance. Notice that the csv python library I used was included in Maximo out-of-the-box but it is not available to autoscript by default. Thus, we have to append the Lib folder to the library path at line 7.

I created it as a script without a launch point:

To confirm that it works, I call the script by accessing this URL from the browser:

Once confirmed working, I created a cron task to run the script on a schedule. We can also modify this script to address some simple file-based integration requirements by changing the delivery method to SFTP or HTTP POST.

Update: We can also use Apache POI library (included in Maximo OOTB) to export data in Excel format and send as email attachments

ArcGIS to Maximo synchronisation not working due to API limit

How to send ArcGIS data to Maximo

This is a weird issue with the ArcGIS – Maximo integration cron task. I like to record just in case it hits me again. 

Symptom:

The client reported the Maximo – ArcGIS Asset integration stopped working. New assets are not synchronised from GIS to Maximo by the ArcGISDataSync cron task. The history of the cron task instance shows an error: BMXAA6361I – caused by: BMXAA1482E – The response code received from the HTTP request from the endpoint is not successful. Not Found

If I copy and open the same REST query of the cron task instance from a browser, ArcGIS does return data with HTTP response Code 200 – OK, the response JSON data looks normal. 

However, the GIS specialist advised me that the request exceeded ArcGIS’s API limit was set at 2000. When inspected closely, there is an attribute “exceededTransferLimit”: true at the end of the JSON response. In this case, the feature layer contained more than 5000 records in the updated state that met the request’s filter criteria (MXCREATIONSTATE=1)

Cause: 

To confirm the GIS limit caused the issue, we increased it to 10,000. The cron task ran without error after that. It is unclear how Maximo captures this error message; whether it read the JSON message looking for the exceededTransferLimit attribute or whether Maximo received a different HTTP status code from ArcGIS. We didn’t have time to debug Maximo’s code to find out.

Solution:

To fix the issue in this case, we resorted to a short-term solution, which is increasing the limit to 10,000 to clear the batch. Then we reset it back to default as it wasn’t expected to have more than 2,000 features updated/created per day.

For the long term, I proposed two options:

  • Option 1: increase the limit to 10,000 or higher permanently. I don’t think it causes much stress to the servers. If we have more than 10,000 updates per feature layer per day, it will still fail.
  • Option 2: Set this layer/cron task instance in Maximo to run more frequently (i.e. hourly). This is processed by the background JVM and won’t cause performance degradation to the end-users. When the cron task runs but does not get any result, it doesn’t consume much resource anyway. However, this approach won’t help if we have a large batch update in a short period (e.g. manual data import or bulk update).

Send HTTP Request from Automation Script (Improved version)

Introduction

In an earlier post, I talked about how to use Automation Script to send an HTTP request by invoking a pre-configured End Point. That approach has some flexibility as we can override various properties during runtime like URL, Headers, or HTTP Method. Despite that, it is still quite limited and only suits simple scenarios.

In a recent task, I had to port an ArcGIS interface from Java to Autoscript. I improved the approach a little bit to address this real-world requirement. I document the simplified version here as it can be handy for me in the future. I hope that it is useful to some of you out there too.

Note: I use Webhook.site to test the code. It is free to use. If you like to test the code yourself, you will need to visit the site first to generate your own Webhook URL

Acquire a unique URL from webhook.site

Example 1: GET Request

I need to send a request to ArcGIS to get details of a Control Valve. It is a simple GET request with some parameters. Below is a basic example.

I created this as a script on the Asset Save launch point. It lets me to trigger the code easily by updating an asset record. When a request is sent to Webhook, it shows the request details including Parameters and Headers. Notice that in this case, it correctly decoded the basic authentication to a username/password pair for the MAXADMIN account.

Inspect Parameters and Headers of a request

Now, if I update the URL to point to a sample ArcGIS online server as in the code below, I can retrieve the details of an asset.

Below is what we see in Maximo.

Show response details in Maximo

Example 2: POST request with form data

In this example, I want to send a Service Request to ArcGIS. To add or update a feature, we need to send a POST request and the content should be in form-data format. Below is a basic example. It includes building a JSON object, converting it to string, and then sending it in form-data format.

I created it as a script on the “Save” event of the “SR” object. In this initial version, we send it to Webhook first to ensure the request is formatted correctly. As shown in the screenshot below, the form data is read correctly.

Inspect to ensure form values can be parsed from request body

Now to make it real, I updated the code to send it to ArcGIS online server. In this case, I hardcoded the coordinate value to the Naperville  City Hall. Determining the X and Y coordinate of a Service Request based on Asset or Location is out-of-scope of this post.

To trigger the script, I update a random Service Request in Maximo. If a new feature is created successfully, we will get a message with an Object ID as follows.

Show Object ID of the new feature in Maximo

We can open ArcGIS Online map, zoom into the area near Naperville City Hall and we should be able to see the new SR as a green point on the map

Service Request is created in ArcGIS Online

Auto-resize images when uploading attachments with Automation Script

Problem with large images

In recent years, there has been a surge in the adoption of mobile solutions for Maximo. For many companies, the use of mobile apps is no longer restricted to the work execution process. Processes like raising service requests or carrying out field inspections have become mainstream. These use cases often involve uploading a lot of photos taken directly from the phone with high-resolution cameras. This leads to a high demand for attachment storage. The time and bandwidth required to view large files via mobile network is also a concern.

Approaches

Often, high-resolution photo is not needed, and we want to resize the file to address this problem. Unfortunately, Maximo doesn’t have this functionality supported out of the box.

Asking the end-user to resize large photos before uploading is not practical. It is our job to make it easier for the user, not make it harder. I have seen different clients having different approaches to keeping file sizes small. But they often involve Java customization which I don’t like.

The best approach is to resize the photo in the mobile application before uploading. But it is dependent on whether the mobile solution has the functionality or can be customized to do it.

Auto-resize images when upload with Automation Script

The simplest solution I have is to use an automation script to resize a photo when uploading. All we have to do is create an Automation script on the Save event of the “DOCLINKS” object with the bit of code below:

Hope this helps.

Maximo fails to connect to SQL Server database

In a recent upgrade, I had to get Maximo 7.6.1.2 to work with SQL Server 2019 (15.0.4198.2 – Jan/2022). 

Initially, I thought I needed to replace the JDBC driver that comes with Maximo with the latest JDBC driver version (10.2). However, it doesn’t solve the issue.

After searching the Web, I came across an article which suggests the problem is due to the new SQL Server version requires SSL protocol TLS 1.2 .

Thus, I managed to fix the issue by adding this parameter to the end of the JDBC connections string: sslProtocol=TLSv1.2;

The full connection string will look as follows:

mxe.db.url=jdbc:sqlserver://;serverName=[SERVERNAME];databaseName=[DBNAME];portNumber=1433;integratedSecurity=false;sendStringParametersAsUnicode=false;sslProtocol=TLSv1.2;

The other method that seems to work too is adding this parameter: -Dcom.ibm.jsse2.overrideDefaultTLS=true to the JVM argument of the Application server, or execution command of any tools running Java such as ScriptBuilder.bat, UpdateDB.bat or IntegrityUI.bat

For example, for the integrityui.bat tool, I edit the file and update it as below:

@..javajrebinjava -Dcom.ibm.jsse2.overrideDefaultTLS=true -Dswing.handleTopLevelPaint=false -classpath %MAXIMO_CLASSPATH% psdi.configure.UpgradeUI -i

Update Aug/2023: I recently had the following database connection error when running UpdateDB.bat with SQL Server 14 SP1:

com.microsoft.sqlserver.jdbc.SQLServerException: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: "com.ibm.jsse2.util.j: PKIX path building failed

Without digging into which version of TLS is being used, I got it running by adding the following two parameters to the connection string in maximo.properties file:

encrypt=true;trustServerCertificate=true
« Older posts Newer posts »