Select-type Data Items are Data Items that can be populated by selecting from a list of registered data. For example, if the list contains employee information, each employee may have an email address and team affiliation in addition to their name.

This article discusses the mechanism whereby specifying a selection in a Select-type (Search Select) Data Item automatically sets information related to the selection in other Data Items.

Specifically, this function allows:

  • The person in charge of processing to specify an employee in a Select-type Data Item
  • The designated employee’s [email address], [name], and [team name] are automatically entered into the String-type Data Items, respectively

How to Achieve this by Decorating the Form Screen (Professional)

In the Professional edition, you can specify a <script> tag in the [Description] field in the Data Item settings. Here you can write a script to automatically set values for Data Items on the processing form.

Questetra Form JavaScript API

By using Questetra Form JavaScript API, you can get and update the values of Data Items on the form screen. It is also possible to call specific processing when the value of a Data Item is updated.

Reference: R2132: Questetra Form JavaScript API

In this article, we will write the code (script) that performs the following processing using Questetra Form JavaScript API.

  • Activates when the Operator makes a selection of a choice in a Select-type Data Item
  • Parses the Display Label of the selected choice
  • Sets the parsed string to the respective String-type Data Item

A script will be installed in the sample App created in the aforementioned Managing Employee Information in Google Spreadsheets with Workflow Apps to achieve automatic input.

In this workflow App the following has been created:

  • A choice master with the Display labels “Team Name / Full Name / Email Address”
  • The above choice master is referenced in the Data Item [Employee master (for reference)]
  • The String-type Data Items [Email Address], [Full Name], and [Team Name].

The moment the Operator selects an employee on the Task Operating screen of this App, the script will set values for [Email address], [Full Name], and [Team Name].

Script Settings

Where to enter the settings

Scripts are set in the [Description] field of the Data Item settings screen. The script will behave the same way regardless of in which Data Item it is set, as long as the Data Item is marked [Editable] or a Guide Panel-type Data Item that is marked [Display Only] in the target Task Operating screen.

In the sample App we will set this in the [Description] field of the [Employee Master (for reference)] (Select-type, search select).

Setting Details

Enter the following code in the [Description] field.

function user_qbpmsFormSet() {
  const choice = qbpms.form.get("q_staff");
  let displayLabel = choice[0].display ;
  let info = displayLabel.split(" / ") ;
  qbpms.form.set("q_staff_team", info[0]) ;
  qbpms.form.set("q_staff_name", info[1]) ;
  qbpms.form.set("q_staff_email", info[2]) ;

qbpms.form.on('change', 'q_staff', user_qbpmsFormSet);

Each line is explained below.

function user_qbpmsFormSet() {  

This defines the name of the function that will operate when the event fires. Names starting with user_ are recommended to distinguish them from those defined by Questetra in the workflow infrastructure.

choice = qbpms.form.get("q_staff");

This defines the variable choice and specifies the choice selected in q_staff ([Employee Master (for reference)]) as the content.

 displayLabel = choice[0].display ;

This defines the variable displayLabel and specifies the Display Label of choice in its content. The [0] is for specifying the first choice (even though there is no the second or the third), and is required for Select-type data.

info = displayLabel.split(" / ") ;

The variable info is defined and its content is the displayLabel divided by ” / “. Since the Display Labels are in the format “Team Name / Full Name / Email Address”, they should be divided into each part. Since there are spaces before and after the ” / “, spaces are removed from the array by including them as delimiters.

qbpms.form.set("q_staff_team", info[0]) ;
qbpms.form.set("q_staff_name", info[1]) ;
qbpms.form.set("q_staff_email", info[2]) ;

An array of info is set for each Data Item of q_staff_team ([Team Name] String-type) q_staff_name ([Full Name] String-type) q_staff_email ([Email Address] String-type) respectively.

qbpms.form.on('change', 'q_staff', user_qbpmsFormSet);

This registers an event handler. When a selection is made in [Employee Master (for reference)] (q_staff ) the defined function (user_qbpmsFormSet) is executed.

[Employee Number] was not included in the Choice Master used in the sample App, so it was not included in the auto-set. If it is registered in the choice master, other information can also be automatically set.

Automatic input reduces the labor of process workers and improves work efficiency. Please consider it as a method of input support using decorations.

Appendix: Realization Method Without Professional Edition

In the Basic / Advanced editions, the tag cannot be used to decorate the form screen, so the Questetra Form JavaScript API cannot be used.

There is no alternative in Basic, but Advanced users can achieve auto-filling for multiple Data Items in the following way.

How to Get Information from Google Sheets (Advanced)

Select-type Data Items have two elements: [Display Label] and [Choice ID]. However, if there are multiple fields, such as “email address” and “team,” there may be a way to store and use that information externally (e.g. in a Google Sheet).

Please refer to the Employee Employee Acquisition/Update Flow in Managing Employee Information in Google Spreadsheets with Workflow Apps for the specific way to achieve this.

The application in this article uses the built-in automatic process [Google Sheets: Get Row]. By specifying the Data Item for each column you can use the automatic process function that saves data of acquired rows to set the values for each of the [Email Address], [Full Name], and [Team Name] Data Items.

However, you will have to wait until the next Human Task [Confirm/Edit Info] to select the employees who will be retrieved and set the values in [Email Address], [Full Name], and [Team Name].

Note that by adding spreadsheet columns, information such as phone numbers and addresses can also be registered. In addition to employee information, customer information, equipment rental records, and other information managed in spreadsheets can be used in a wide range of applications.

  • Up to 10 items (columns) can be automatically set in a single [Google Sheets: Get Row] process
  • If there are 11 items or more, please set up multiple automatic processes and separate the items to be retrieved
%d bloggers like this: