Creating a Maximo Cron Task without a Java Class file

Normally if you want to create a cron task to perform some function in Maximo, you would have to create a Java Class files and build and deploy it with the ear. However, custom java class development is being discouraged by many companies and trying to deploy a class file in a cloud environment can be challenging at best. It turns out that you don't have to create a java class file to create a cron task. Instead you can create an Automation Script to perform the same function and then call/schedule your automation script from the cron task screen. Since in an automation script you have full access to the java library, there is little you can do in an class file that you can't do in an automation script. This is possible because of a built in class file from IBM that will call your class file for you. You can even pass in parameters to your class file. Here is how.

Automation Script

  1. In the Automation Scripts application, on the List tab, select the Create > Script action.
  2. Specify a name, description, and log level for the script.
  3. If the script requires variables, in the Variables section, add new rows to declare the variable and bindings. You cannot specify bindings to a Maximo® business object. You can specify only LITERAL, SYSPROP, and MAXVAR bindings. No mbo fields allowed.
  4. Enter the source code of the automation script and click Create to save the automation script in the database.

Cron Task

  1. In the Cron Task Setup application, create a new cron task definition.
  2. Enter a name and description for the cron task.
  3. In the Class field, enter com.ibm.tivoli.maximo.script.ScriptCrontask. (copy and paste as case matters)
  4. In the Cron Task Instances section, add a row.
  5. Specify the cron task instance name.
  6. Set the schedule for when the cron task is run.
  7. Select Run As User. The security authorizations that are granted to the specified user determines whether business logic that is related to Maximo business object can run in the script code. For example, a value cannot be set in a record unless the specified user has the security authorization to write values into that record.
  8. In the Parameters tab, in the SCRIPTARG row, specify a value(s) that represents an argument for the cron task. To specify more than one value, separate them by commas. This is where you pass in values to the script.
  9. In the SCRIPTNAME row, specify the name of the script that you created to run as part of the cron task. SCRIPTNAME is a mandatory parameter that must be populated. The script name that you specify is passed to the automation script in the form of the scriptName implicit variable.
  10. In the Details section, select the Active check box to activate the cron task instance.
  11. Save the record.

To access the values from SCRIPTARG, in your automation script, you access a variable call 'arg'. Here is an example of how to access it:

if arg:
   srOwner,wfProcess = arg.split(",")

This example assumes that the cron task will be passing in two variables, the owner of the SR and the workflow process name. Also, using the split method we can use something other than a comma as the delimiter for the arguments, in case you need to pass in a comma for some reason.

Remember, since you are calling this from a cron task and not a screen, there is no mbo object attached. This means the variable 'mbo' is undefined in your script.

So let's talk about the pros and cons of this approach.

Pros:

  • No class file to deploy
  • Can be implemented in a cloud hosted environment without the need for file or web server access.
  • Changes are instant, so quicker debug times (no rebuild/deploy)
  • Development language is not limited to Java (see Maximo's supported Automation Script Languages).

Cons:

  • Interpreted script so will be slower for processing large amount of data.
  • Passing in parameters can be awkward since they have to be a comma delimited list.

Happy coding.

#Maximo

How to add new crontask parameters expect scriptname and scripttag? Michael (M.L.) Chrisman

Like
Reply

🔥 Ready to conquer IBM Certification? Ignite your success with EduSum expertly designed prep! 🔥 #CertificationConquer #SuccessIgnition www.www.edusum.com/ibm

Like
Reply

You have a brilliant mind my friend. Thank you for this.

Nice piece of information 👍

To view or add a comment, sign in

More articles by Michael (M.L.) Chrisman

Others also viewed

Explore content categories