Tuesday, 16 April 2019

Create new Crontask based on Automation Script | Maximo



Step 1. Create a Script with any Name, as in my Example my Script Name is CRONAUTOMATIONSCRIPT


from psdi.server import MXServer
from psdi.util.logging import MXLoggerFactory

log = MXLoggerFactory.getLogger("maximo.script.aqautoscript")

mxserver = MXServer.getMXServer()
userInfo = mxserver.getSystemUserInfo()

 # arg = crontask scriptarg parameter 
if instanceName and scriptName and  arg:
    AssetSet = mxserver.getMboSet("ASSET", mxserver.getSystemUserInfo())
    AssetSet.setWhere("ASSETNUM = '" + arg + "' ")
    AssetSet.reset()
    asset = AssetSet.getMbo(0)
    if asset:
        asset.setValue("description",arg)
    AssetSet.save()
    
log.info('\n instanceName is: ' + instanceName )
log.info('\n ARG is: ' + arg)
log.info('\n Automation Script name: ' + scriptName)


Step 2. Create a New Cron as below. and enter the name of the script into the parameter of Script Name.

Name: anyName, CRONAUTOMATION

Class:com.ibm.tivoli.maximo.script.ScriptCrontask

Cron Task Instances: CRONTASKINSTANCE

Parameters:

    SCRIPTARG:    (Any argument you want to pass to the script, and the script will get this by "arg" implicit variable.)

    SCRIPTNAME:   CRONAUTOMATIONSCRIPT (we created in step 1.) 



 

Note: If you create a comma-delimited list of values that you want to pass to the Automation Script in the SCRIPTARG parameter, you can access them in the script with something like: if arg: srOwner,wfProcess = arg.split(",")

No comments:

Post a Comment