From Maximo 184.108.40.206 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
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.reset() prMbo = prSet.moveFirst()
prMbo.setValue("DESCRIPTION", "Modification via PR Async Job Worked ")
Add this Asynchronous Job Script Name in “ASYNCJOBNAME” Domain as shown below:
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")
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.
Maximo Technical Consultant at EAM360