Home >

On this page

AX2196

Setting up a Scheduler job for use with triggers

File group triggers are used to automatically execute Scheduler jobs after changed data is saved from plan files in that file group. If you want to use a trigger, you must create one or more Scheduler jobs that are specifically designed for use with the trigger.

The Scheduler job can be set up to run any task, on any file or file group in the system. There are no limitations on what the Scheduler job can do once it has been triggered.

The Scheduler job must contain the following:

  • An event handler with the same name as the trigger event name. The event name is what links the trigger to the Scheduler job(s) to execute.
  • If the trigger has defined variables, and you want to use those variables to affect the execution of the Scheduler job in some way, then you must:
    • Create corresponding job variables in the Scheduler job, using the same names as the trigger variables.
    • Use the variables within the job settings to achieve the desired outcome.

Optionally, you can also set up the job to use the notification addresses defined for the file group.

You can run any number of Scheduler jobs as the result of a file group trigger. When data is saved from plan files and the trigger events are evaluated, Axiom Software looks for any jobs that contain an event handler with the same name as the trigger event.

Creating the event handler in the job

To associate the Scheduler job with the file group trigger, you must create an event handler within the job with the same name as the trigger event.

For example, if the name of the trigger event in the file group is BudgetUpdate, then the Scheduler job that you want to run as a result of that trigger must contain an event handler named BudgetUpdate.

Example file group trigger event

Example Scheduler job event handler

Both the file group trigger event and the Scheduler event handler must be enabled (active) in order for the Scheduler job to be executed as a result of the trigger.

When creating the Scheduler event handler, you must determine whether to execute it as the job Owner, or as the job Requester. For the purposes of file group triggers, you most likely want to run the job as the owner. The "requester" in this case will be any user who saves a plan file in the triggering file group. That user may not have access to whatever file or file group that you want to trigger for execution in the Scheduler job. Therefore, if you want the triggered Scheduler job to always run when triggered, it should be set to the owner.

Using variables in the job

If the file group trigger has defined variables, you can use the variables in the Scheduler job to impact the job execution in some way.

To use the trigger variables in the Scheduler job, you must:

  • Define a job variable with the same name as the trigger variable. For example, if the trigger variable is named DEPT, then you must create a job variable with the same name. For example:

    NOTE: It is recommended to define a default value for the variable. Leaving the default value blank may cause a validation error in the job settings, if blank is not a valid value where the variable is used. In this example, the default value is intentionally a non-existent department number; its sole purpose is to prevent validation errors within the Scheduler job settings.

  • Use the variable in the job settings as needed to achieve the desired results. Place the variable in curly brackets as normal. For example:

  • If the variable is being used in a filter (like in the example above), keep in mind the following:

    • IN syntax should be used so that the filter will be valid when the trigger variable returns multiple values.
    • If the trigger variable points to a string column, you do not need to place quotation marks around the variable when creating the filter. When the variable values are passed to Scheduler by the trigger, they will be automatically placed in quotation marks as necessary. Extra quotation marks will cause an error. However, keep in mind that your default variable value defined in the Job Variables section should have quotation marks, if you want to use the default value for testing.

In this example, we are using a file group trigger to automatically execute a Process Plan Files job for a second, dependent file group. In this particular case, both file groups use the DEPT table as the plan code table. For every department code where changed data was saved in the first file group, we want to process the plan file for that same code in the second file group. Therefore DEPT is used as a variable.

Imagine that a Process Plan Files utility was run for the first file group, and three plan files had changed data: 100, 400, and 500. Since the trigger variable is based on the DEPT column, it will pass those values to the Scheduler job as a comma-delimited string (including quotation marks as necessary). In the Scheduler job, this will cause the filter to be resolved as DEPT IN (100,400,500), and therefore those three plan files will be processed for the second file group.

Setting up email notifications for the job

When you set up the Scheduler job for the trigger, you can use the standard email notification addresses, or you can use the optional notification addresses for the triggering file group.

Using the standard email notification addresses, you can specify "hard-coded" email addresses, or you can use system variables such as {CurrentUser.EmailAddress} or {JobOwner.EmailAddress}.

The optional notification addresses for file groups can be used to provide a more granular level of notification. For example, you can define unique email address for each individual code in the plan code table if desired. Using the {NotificationAddress} system variable, you can send notifications to those file group-specific notification addresses.

For more information, see Using email notifications with triggers.