6 Implementing a Job
6.1 Implemented Function description
When a Trigger is launched the Job Macro is executed. A Job Macro must implement the following function:
Function:
o RunScheduledJob
Parameters:
o mgobjJob As MegaObject
- This parameter is the object describing the Job.
- Use GetTypeObject().Explore on a Job MegaObject to explore the Job type.
- In particular, use GetContextString() Method to recover the string set at Trigger registering (see AddTrigger).
o objJobResult As Object
- This parameter is the object enabling to return information needed by the Scheduler after the Job execution.
- The objJobResult parameter type is composed of the following properties to be set into the Job implementation
• DiagMessage As String: a diagnosis message used when the job succeed.
• ErrorMessage As String: an error message in case of job failure (when the Job Function returns False to indicate the job failure).
• RemoveTrigger As Boolean: in case of job success, set blnRemoveTrigger to True to remove the job trigger so that the job will not be executed anymore.
6.2 Job Function Template
'MegaContext(Fields,Types)
Option Explicit
' Function : RunScheduledJob
' Description : Implement this function to specify what to do when a job is triggered.
' Parameter :
' - mgobjJob : object describing the job (this object is not a repository object)
' - objJobResult : object enabling to return some informations
' * DiagMessage As String : a diagnosis message used when the job succed
' * ErrorMessage As String : an error message in case of job failure => return False to indicate job failure
' * RemoveTrigger As Boolean : in case of job success, set blnRemoveTrigger to True in order to remove the job trigger so that the job will not be executed anymore
' Return :
' - Boolean : return True in case of job success or False in case of job failure, in this case, set an error message into strErrorMessage
Function RunScheduledJob (mgobjJob As MegaObject, objJobResult As Object) As Boolean
' Initializing variables
Dim mgRoot
Set mgRoot = mgobjJob.getRoot()
' Write some code here ...
' Return True in case of job success
' Return False in case of job failure, in this case, set an error message into strErrorMessage
RunScheduledJob = True
End Function