Executing Asynchronous Job Using Maximo Automation Script

Introduction:

From Maximo 7.6.1.2 onwards, IBM has enhanced the Automation Script to support scripts that can be run as asynchronous jobs.

Asynchronous Jobs are mainly used to run a task or perform business logic in the background.

For Example, When the User generates a work order from PM Application, This action triggers an Asynchronous Job which will run in the background to create the work order.

The user needs not wait until the job is completed. Earlier, this was achieved by creating Java Class Handlers and now it is available in Automation Scripts.

This approach will be very handy if we need some tasks to be run at a user-defined time as we don’t want to create escalations / cron task instances.

Use Case: Let us see how to set PR Description Asynchronously

Step1:

In the Automation Script Application, create a script to define the logic for Asynchronous Job.

I have added a “PRASYNCJOB” script as shown below:



    prSet= service.getMboSet("PR", userInfo)
prSet.setWhere(whereclause)
prSet.reset()
prMbo = prSet.moveFirst()
if prMbo:
prMbo.setValue("DESCRIPTION", "Modification via PR Async Job Worked ")
prSet.save()
prSet.close()
Step2:

Add this Asynchronous Job Script Name in “ASYNCJOBNAME” Domain as shown below:



Step3:

In the Automation Script application, add a script to run the asynchronous job. I have created a script for PR Object Launch Point

I have registered the Asynchronous Job script “PRASYNCJOB” in the MAXASYNCJOB table by specifying the non-persistent Maximo business object (MBO) “ASYNCSCRIPT”





asyncSet = mbo.getMboSet("PRASYNCSCRIPT", "ASYNCSCRIPT","1=1")
asyncMbo = asyncSet.setup()
asyncMbo.setValue("AUTOSCRIPT","PRASYNCJOB")
asyncMbo.setValue("OBJECTNAME","PR")
asyncMbo.setValue("WHERECLAUSE","prid="+str(mbo.getUniqueIDValue()))
asyncMbo.execute()
Step4:

Now, Create a PR without a description and save the record & then refresh the PR record and note that the description field is updated via the async job script.



Note: Make sure that AsyncScheduledJobCron is running.

Benefits: Using Asynchronous Job, we can make sure only one of those processes will run at any given instance of time and also, ensures that the background tasks aren’t running on the UI JVM.

Selvaraj

Maximo Technical Consultant at EAM360

Explore More About EAM360

Submit your email with us to connect and discuss more about the EAM360 mobile applications and how we can enhance your Enterprise Asset Management processes.