How to get application name in automation scripts

IBM claims the you can use the implicit variable ‘app’ in automation scripts if you need to know the name of the Maximo application that is currently running. Unfortunately, this technique works only on the main object on which the application is defined.

As an example, try to define the following automation script on the “before save” event of the SPAREPART object

if app == 'ASSET':
  service.error("cx", appname, [])

If you open the Assets application and try to update records in the Spare Parts table, you will see that you the error message will not be triggered because the ‘app’ variable will be empty. This is because the main object of the Assets application is ASSET and not SPAREPART.

There are two alternative approaches to get the application names in this cases.

The first one is to use the MboSet().getParentApp() method:

appName = mbo.getThisMboSet().getParentApp()

Another technique is to use the WebClientSession.html.getCurrentAppId() method like this:

appname = service.webclientsession().getCurrentAppId()

Note that the getCurrentAppId() method will return the application name in lowercase.

How to get application name in automation scripts

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top