· Sep 13, 2022

Setting up Task for User Defined Class File

I have created a class file that I want to execute daily to gather Metrics (Message Header, Space Available, etc..) and write the data into a Cache table. Now that I have written the class I want to add it to the Task Scheduler within Ensemble to run every morning. How do I go about getting the class file created as a Task within the Task Scheduler? The Documentation isn't as clear cut for creating custom tasks as one would expect.

Product version: Ensemble 2018.1
$ZV: Cache for UNIX (IBM AIX for System Power System-64) 2018.1.3 (Build 414U) Mon Oct 28 2019 11:24:02 EDT
Discussion (5)2
Log in or sign up to continue

@Scott Roth - you can create a New Task instance via the "Task Schedule Wizard" in the System Management Portal, and in the "Task Type" field, select "RunLegacyTask".  Then in the ExecuteCode field, simply type the command to run the desired method in your class.  Then you can enter the rest of the details of the Task accordingly (when to run, how often, etc) and it will make the call to your class whenever the Task runs.  

Please let me know if more clarification would be helpful.

I have an example implemetation in the Ompare tool.


Extends: %SYS.Task.Definition

Implements: OnTask method

By the way, you can run Schedules programatically from IRIS Session outside of the Task Scheduler if you are investigating / debugging the behaviour. For example:

set tBASE=##class(ompare.Schedule).%New()
set tBASE.Environment="BASE"
set tBASE.RunSourceHandlers=1
set tBASE.ExportToFile=1
set tBASE.ExportDirectory="C:\TMP\ompare\"
set tBASE.ExportCompression=0
set tBASE.DiscardProfileData=1
set tBASE.RetainExportDays=0
set tBASE.IncludeSourceCode=1
set tSC1=tBASE.OnTask()

The reason I would subclass %SYS.Task.Definition is that the Management Portal knows how to display input configuration fields for your class properties.

This is more visably useful / supportable. Easier to see the task paramaters.

They can have validation also (Required, Pattern, MINLEN, MAXLEN, Setter methods, %OnSave methods).

Hope that helps :)