This content is dedicated to our next version. It is work in progress: its content will evolve until the new version is released.

Before that time, it cannot be considered as official.

Interact with tasks

Discover how to interact with tasks from a Bonita UI Builder application.

  • Difficulty: intermediate

  • Prerequisites: have a project created on Bonita Studio with defined BDM, tasks and contracts

While Bonita UI Builder does not yet support automatic form creation from contract data, you can still easily interact with your tasks, processes, and data.

API resources

There are four Bonita API resources you mostly need to interact with your tasks:

  • GET /humanTask,

  • POST /userTask/execution,

  • GET /userTask/context,

  • GET /bdm/businessData.

To use them, open your Bonita UI Builder application, go to the Queries tab and create a new query to Bonita API.

Human tasks

The human tasks API is useful to retrieve a list of human tasks by applying pagination parameters and filters.

For example:

  • GET | /API/bpm/humanTask?c=10&p=0&f=state=ready&f=caseId=[caseId]

For more detailed information, refer to the human tasks api documentation.

User task execution

The user task execution API executes a task identified by its id.

For example:

  • POST | /bonita/API/bpm/userTask/[taskId]/execution

The task contract values have to be provided in the query’s body:

execute_ht_mngt_task

Here, newEmployeeInput is the contract name, and workspaceLocation and workspaceComments are mandatory inputs of the contract. They take as value what is typed in the newEmployeeWorkspaceLocation and newEmployeeWorkspaceComment widgets.

Please note that a task can only be executed by the right actors, as defined in your Process Diagram.

For more detailed information, refer to the task execution api documentation.

User task context

The user task context API provides the context for a specific user task identified by its id.

For example:

  • GET | /bonita/API/bpm/userTask/[taskId]/context

For more detailed information, refer to the context by userTask id api documentation.

Business data

The business data is useful to find business data with pagination params and filters by invoking a Named Query. It allows to call either default or custom business data queries.

For example:

  • GET | /API/bdm/businessData/[businessObject]?q=[query]&p=0&c=10&f=[filterString]=[filterParam]

  • GET | /API/bdm/businessData/com.company.model.Claim?c=1000&p=0&q=find

q=[query] is a mandatory parameter. Queries are used to get information about data objects stored in the database. A set of default queries, find and find_by, is defined automatically for each object in the BDM. You can also create custom queries.

For more detailed information, refer to the business data api documentation.

Manage tasks from the application

You can interact with tasks from your Bonita UI Builder application in many different ways.

Let’s say you want to display your open tasks in a table and interact with them directly from the table.

Display a list of tasks

Go to the Queries tab and create the following query:

  • Name: getTasks

  • Method: GET

  • URL: /bonita/API/bpm/humanTask

  • Params:

    • Key: p

    • Value: 0

    • Key: c

    • Value: 10

Then, bind this query to a Table widget in order to display your open tasks.

Interact with tasks from the table

In the table widget, add a new column called "Open task" and select Icon button as column type. Then, on the OnClick property, select Show Modal and create a new modal:

create_modal

Here, we will create a modal that will execute the "Review and answer claim" task from the Getting Started tutorial. The modal should look like this:

modal_task

Go back to the Queries tab and create the following query:

  • Name: executeReviewAndAnswerClaim

  • Method: POST

  • URL: /bonita/API/bpm/userTask/{{Table1.triggeredRow.id}}/execution

  • Body:

{{
  {
    claimInput: {
      answer: Input1.text
    }
  }
}}

The claimInput contract of the task expects a parameter called 'answer', which will be fetched from the Input1 widget.

This query will use the task id fetched from the table (Table1.triggeredRow.id) to execute the task.

Then, open the modal and bind the executeReviewAndAnswerClaim query to the Onclick property of the confirm button:

bind_confirm_modal

If you have other tasks you would like to manage, you can create new modals and new execution queries in the same way.

To make sure you open the right modal, you can add the following code in the Onclick property of the "Open task" column: {{ currentRow.displayName === "my task name" ? showModal(Modal1.name) : currentRow.displayName === "my other task name" ? showModal(Modal2.name) : null }}

Retrieve business data

If you would like to display business data, context and information from your previous tasks, here is what you should do:

  • Call GET /userTask/context to retrieve a storageId. For example: GET /bonita/API/bpm/userTask/{{Table1.triggeredRow.id}}/context

  • Call GET /API/bdm/businessData to retrieve your business data, using the storageId returned previously. For example: GET /API/bdm/businessData/com.company.model.Claim?c=1000&p=0&q=findByPersistenceId&f=persistenceId={{storageId}}

These steps could be done for example in a JS object and bound to a widget.