Tasks
  • 19 Mar 2024
  • 5 Minutes to read
  • Dark
    Light

Tasks

  • Dark
    Light

Article Summary

General

Tasks are a collection of Actions that can be executed on a regular basis using Execution Plans or by a request through the Hub or the API.

Example: A task can be used to automatically create report documents using a Create Report Document Action and distribute them (e.g. by e-mail using a Send E-Mail Action).

Managing Tasks

Tasks can be managed by logging on to the Management Service and clicking Tasks in the menu.

Properties

Every task has the following properties:

Name

Description
NameThe name of the task.
DescriptionThe description of the task.
Has TimeoutWhen enabled, the task has a timeout; if its execution time exceeds the timeout, it will be aborted.
TimeoutThe timeout of the task. This property is only applicable if Has Timeout is enabled.
ParametersA list of parameters of the task (see below).

Parameters

By using parameters you can allow to pass information to the execution of a task.

Example: Let's suppose you have a task that creates one report document for every sales representative. By default you want the task to create report documents based on the previous month. However, you want to allow callers of the task (e.g. when the task is executed by an API request or by a User through the Hub) to override the default behavior and allow them to specify another month than the previous one. In that case you can add a parameter that contains the year and the month (or two parameters, one for the year and one for the month) and default them to the previous month.

Parameters can be accessed in Expressions in the context of the task by using a Task Parameter Placeholder.

Parallelization

Some tasks perform a lot of work that can be sped up by splitting it up into individual jobs which can all run at the same time.

Example: If you have a task that performs a Cycle over 1000 values the task could be split up into 5 jobs each processing 200 values.

This can be achieved by defining a task parameter that contains value that shall evenly be distributed among the parallel jobs. Each job will essentially execute the task with only the values of that parallelization task parameter being different. The following properties can be set to control parallelization:

Name

Description
Enable ParallelizationTrue. Parallelization is enabled and the task will be split up into multiple jobs.

False. Parallelization is disabled for this task.
Number Of JobsAn Expression that returns a Number that equals the number of jobs to parallelize the task.
ParameterThe name of the task parameter whose values shall be evenly distributed among the jobs.
WARNING

The execution of a parallelized task follows an all-or-nothing principle; every parallelized job requires a free execution slot (the total number of execution slots is determined by the activated license). Jobs created from a task will only be executed if there are enough free execution slots for all the jobs. If a task is due to be executed and not enough free slots are available the task will be skipped and no job created from that task will be executed. This behavior is by design to prevent situations where only parts of a task are being executed.

Example

Let's suppose you have a datasource that contains a Country field and a Sales Rep field; each sales rep is associated with a single country in the data model of that datasource. Let's further suppose you have a task that filters the data model to four countries (Germany, Austria, Switzerland, and USA) and then cycles through all sales reps, creates a report for each sales rep and distributes it. If you don't parallelize that task, a single task will sequentially cycle through all sales reps of any of the four filtered countries. This could potentially take very long.

To parallelize this task you can create a new task parameter, name it Country and add all four country names as values for that task parameter:


Parameter Configuration

The first action of the task should then be a Filter Datasource Field Action which filters the datasource field Country to the values of the task parameter Country. The value to filter to would look like this:

Filter Value Expression

[TaskParameter].[Country]

The other actions of the task would then be the Cycle over the field Sales Rep and all other actions required to create and distribute the report document.

In the parallelization settings of the task, Enable Parallelization needs to be selected and the Parallelization Parameter needs to be set to the Country parameter that you have previously created.

Now let's suppose you add the following expression as Number Of Jobs:

Number of Jobs Expressions

2

The resulting configuration should look like this:


Parallelization Configuration

When this task is being executed, it will be split up into two jobs and all values of the parallelization parameter (Country) will be evenly distributed among those two jobs. Since in our example the Country parameter has four values, each job will have two values assigned. Job number 1 will have Germany and Austria assigned and therefore only filter those countries in the datasource, thus only cycling through all sales reps of those two countries. Job number 2 will do the same for the remaining two countries (Switzerland and USA).

Now let's suppose your Number Of Jobs expression would look like this:

Number of Jobs Expressions

5

In that case Mail & Deploy only create four jobs, because we only have four values for the parameter Country and there is no way to create a fifth job.

The Number Of Jobs expression can also be dynamically set:

Number of Jobs Expressions

[TaskParameter].[Country].Count() / 2

In this case Mail & Deploy will dynamically calculate the number of jobs based on the number of values of the Country parameter. Since the Country parameter has four values in our example, Mail & Deploy will assign two jobs (four divided by two). If, however, you change the Country parameter to have six values, Mail & Deploy will automatically create three jobs (six divided by two). The only thing to consider is the fact that your Mail & Deploy license has a limit for the maximum number of parallel executions (so if your calculation returns a number of jobs of 20 but your license only permits 10 parallel executions, that task will not be executed and therefore skipped).


Was this article helpful?

What's Next