How to update a data context variable in a user task using a UserService

How to update a data context variable in a user task using a UserService

book

Article ID: KB0073581

calendar_today

Updated On:

Products Versions
TIBCO EBX All versions from 5.8.0.

Description

In this article, we will give an implementation of UserService that, when used in a user task, allows the user to update a workflow data context variable.
Before reading this article you should be aware of the UserService API.
Please see links in "reference" section.

In our example, we use a simple workflow that has one data context variable "myVariable", which default value is "initial_value":

User-added image

Resolution

Configuration

Here is the configuration screen of the UserService set as as the user task service:

User-added image

Input parameters:

  • Dataspace: can be left empty
  • Snapshot: can be left empty
  • Data context variablemandatory: it is the data context variable that will be updated in this user task
  • Disable Accept at start: by default, the Accept button will be automatically displayed at the opening of the work item. If the value is 'true', the Accept button will be displayed as soon as the field is updated

Output parameter:

  • Data context variablemandatory: it is the data context variable that will be updated in this user task. At the end of the work item, the variable will be updated with the new value

Results

Here is the screen of the UserService:

User-added image

It contains two fields:
  • Previous variable value: it contains the data context variable value at the beginning of the work item (not editable)
  • New variable value: this is where the user sets the new data context variable value. If this form was previously saved in this interaction, the default value is the last saved value
When pressing Save, the Accept button is displayed (if disable Accept at start value is 'true' in the configuration).
The new value is then copied into the output parameter at completion of the work item, and the data context variable is updated.

Issue/Introduction

How to update a data context variable in a user task using a UserService

Additional Information

User services documentation:

Attachments

How to update a data context variable in a user task using a UserService get_app
How to update a data context variable in a user task using a UserService get_app