Skip to content

Workflow Tasks

Some process nodes in a workflow will have a task associated with it. The most common process node to use tasks is the "manual" node which is defined as a node where some external manual work needs to be done.

Task creation

Upon create of a job with a workflow or when a workflow is associated with a job, a preprocess will execute on the workflow. This will create a task for any node that is designated to have tasks.

let job = call_tactic("insert", {
    'name': 'My First Job',
    'description': "A descripion of the job",
    'workflow': 'PIPELINE00012',
    'start_date': '2021-04-l0,
})

This will create a job and return the newly created sObject. With this job sobject, you can query for the related tasks.

Get all tasks of a job

To get all of the tasks in a job, you can simply use an expression:

let job_code = job.get("code")

// get all of the tasks
let tasks = call_tactic( "query", {
        search_type: 'sthpw/task,
        search_code': job_code
} )

You can also get a task associated with the workflow of a specific process

let job_code = "JOB00123"; // code for any existing job
let process = "First Approval";

// get all of the tasks
let tasks = call_tactic( "query", {
        search_type: 'sthpw/task,
        search_code': job_code
        process': process
} )
let task = task[0];

Note

It is possible to have multiple tasks per process. You can create as many tasks in a process as you wish. The workflow will not move forward until all of the tasks are complete.

Updating a task status

If you have a task, you can update the data assocated with it. For example, you can change the status of the task.

call_tactic("update" {
    search_key: task,
    data: {
        status: "Complete"
    }
} )

This will the the status of the task to complete.

Note

Although task is a dictionary when returned from the above query, the API will deted this and look at the _SEARCH_KEY _ parameter of the "task" dictionary.

When a status is changed, it will send a message to the workflow. The task and the process in the workflow engine have a close relationship. If a message is sent to the workflow, the workflow engine will alter the task status accordingly. And vice versa, if ta status is changed on the tasks, it will send a message to the workflow engine.

This means that you can control a workflow with only manual nodes through just the tasks.

Retrieve a users list of tasks

A user is often interested in all of the task assigned to them. You can just query the task table directly for this information.

login = "joe";

// get all of the tasks
let tasks = call_tactic( "query", {
        search_type: 'sthpw/task,
        login: login,
        status: "Pending",
} )

When the query returns with a list of dictionaries representing the tas, you can iterate through them to display on a user's dashboard.