Sunday, June 30, 2024

Automation Script as a Cron task

Automation Script can be used to create crontask without any Java customization file.
 
It's widely used option to avoid outage using Java Code for Cron task.

Cron task definition for an automation script has a Class file value and 2 parameters.
 
Class file value should be set to com.ibm.tivoli.maximo.script.ScriptCrontask

Cron task instance parameters: 
SCRIPTNAME - Name of the automation script without launch point
SCRIPTARG - Arguments to pass values to the Script
{"siteid": "BEDFORD","status": "'WAPPR','APPR','WMATL'"}


Automation Script - C_ASCRONTASK 
Script Name should be set as SCRIPTNAME parameter in Cron task
if arg is not None:
   args = service.tojsonobject(arg)
   
   assetSite = args.get('siteid')
   assetValidStatus = args.get('status')
   
   #service implicit variable is used to getMboSet since 7.6.1.2 . MXServer is not needed
   #runAsUserInfo is the userInfo of Cron task Instance
   assetSet = service.getMboSet("ASSET", runAsUserInfo)
   assetSet.setWhere("siteid='" + assetSite + "' and status in (" + assetValidStatus + ")" )
   assetSet.reset()
   
   assetMbo = assetSet.moveFirst()
   while (assetMbo): 
        # more logic 
	assetMbo = assetSet.moveNext()
   assetSet.save()
   assetSet.close()