Introduction

At the time of writing, you can only create drop-downs in the Create Workflow JobClosed The Create Workflow Job tool is used to create a task step that dynamically creates Workflow Jobs. A Create Workflow Job step dynamically generates one or any number of web page(s) containing fields for completion by recipients and publishes them to a web site folder on a specified web server. Each of these web pages is called a "Workflow Job" and can be assigned for completion to any number of recipients. tool that contain hard-coded values.

This article describes how to create a drop-down list for a workflow that is dynamically populated from a recordset.

Required Tools

Other tools may be required to complete the full business process of this task. The tools listed here are only needed to fulfil this scenario:

Database Query (ODBC)Closed You typically use the Database Query (ODBC) tool to extract specific records from a relational database, using a valid ODBC driver to make the connection. These are then made available to other task steps as a recordset. or Database Query (OLEDB)Closed You typically use the Database Query (OLEDB) tool to extract specific records from a relational database, using a valid ODBC driver to make the connection. These are then made available to other task steps as a recordset. depending on your database requirements — This extracts the values from the database that make up the drop-down list
Format as TextClosed The Format as Text tool creates single or multiple text documents, using information provided by Input tools such as the Database Query (ODBC) tool. It requires no global settings. — We use this tool to create the HTML to format the drop-down list
Run VBScriptClosed The Run VBScript tool is used to create a task step that runs a Visual Basic Script using data produced by other steps in the task. — This step converts the output from the Format as Text step to a variable
Create Workflow Job — The final step; this consumes the variable for the required output

Prerequisites

The required dynamic values for the drop-down must be held in a database table accessible by this instance of BPA Platform. The required values must all come from the same table column so that when extracted, they form a single column recordset.

A global connection to this database is required.

Creating the Dynamic Form Input

This section is the "prep-work", creating the code behind the drop-down list.

Extracting the Drop-Down Values

First we must extract the values from the database:

  1. Add the relevant Database Query tool to your task.
  2. Extract the required values.

Creating the Drop-Down List

Now we use the Format as Text step to build the drop-down.

  1. Add a Format as Text step which consumes the recordset created by the Database Query step.
  1. Go to the Formatting tab and enter the following:
Header pane:

<select id="option_select" name="option_select" style="width: 200px;">

Detail pane:

<option value=""></option>

Footer pane:

</select>

  1. From the Task Browser, go to the Environment tab.
  2. Change Scope to be This Step.
  3. Expand RecordSource to see the single column of the consumed recordset.
  4. Drag this column to in between the double-speech marks in the Detail pane.
  5. Drag the same column to be the value between the option elements.

    Your option statement should now look like:

    <option value="{=ThisStep.RecordSource("Values")}">{=ThisStep.RecordSource("Values")}</option>

    (substitute Values for the name of your recordset column)

  6. Click OK to save and close this step.

Converting the Output

The Create Workflow Job step cannot use and process the output from the Format as Text step (see Create Workflow Job - Working With Other Tools) so a conversion must take place first.

  1. Add a Run VBScript step to the task and consume the document from the Format as Text step.
  1. Go to the Main tab.
  2. Create the task variableClosed Variables are created and used extensively throughout and can either have fixed values or values that are dynamically populated when a task is run. Task variables are only available for the specific task they are created for. Users with Task Administrator rights can create task variables. (Type = Variant, Parameter) to hold the Format as Text's output.
  1. Drag the new variable to the script area followed by <space>=<space>.
  2. From the Task Browser, expand Steps > Run VBScript and drag DocumentSource to complete the current line.

    The script should now look like:

    Dynamic Drop-Downs in Create Workflow Job - Run VBScript Step

  3. Click OK to save and close the step.

Adding the Form Input to the Create Workflow Job Step

We can now add the drop-down to the workflow HTML page.

  1. If you have an existing Create Workflow Job step open it, else add a new step to the task.
  2. For the purposes of this article, we do not need to specify an input recordset for this workflow job so can skip directly to the Formatting tab.
  3. Save and Submit buttons are automatically included in your workflow. Add the variable created previously to this workflow above those buttons.
  4. Click Create Workflow Job - Add Hidden Field to add a hidden field underneath the variable — This field is used to hold the value selected by the end-user.
  5. Enter DropDown as both the Attributes: ID and Attributes: Name and click Update to save.
  6. Click Create Workflow Job - Edit HTML and add the following inside the head element:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">$(document).ready(function(){ $('#DropDown').val($('#option_select').val()); $('#option_select').change(function(){ var value = $(this).val(); $('#DropDown').val(value); }); });</script>

where:

DropDown is the variable name
option_select is the ID given to the select statement in the Format as Text step

This script is called when a selection is made in the drop-down to save the chosen value to the hidden field.

  1. Add relevant Publishing and Document Formatting as required — for more information, see How to Add a Create Workflow Job Task Step.
  2. Click OK to save and close the step.

Testing the Drop-Down

At this point, you can test your task to ensure the drop-down contains the correct values.

  1. Add a Send Email (SMTP)Closed The Send Email (SMTP) tool sends messages to any SMTP compliant mail server. This tool is capable of sending multiple messages in either text or HTML formats, incorporating data from Input and Format steps to any number of recipients. If recordset data being used from an Input step includes a column containing email addresses, then this can be used as a "dynamic" recipient address. step to your task but don't consume the Create Workflow Job step.
  2. Choose a Connection where you have access to the email.
  3. In the Main tab, add valid From and To addresses.
  4. Enable Message Only in the Message Contents pane.
  5. From the Task Browser, go to the Environment tab.
  6. Change Scope to Task.
  7. Expand Steps > Create Workflow Job and drag the OutputURL property to the message body area.

    Dynamic Drop-Downs in Create Workflow Job - Send Email (SMTP) Step

  8. Click OK to save and close the step.
  9. To ensure BPA Platform runs the steps in the correct order, the individual task steps must be linked. You do this by clicking a step to display the step controls — click and hold Step control - Draw and draw the connector to its successor.

    If required, you can add a label to the connection. Double-click the connection line and add the label, up to a maximum of 100 characters. Note that this is a pure-text field so variables, formulas, functions, and Task Browser properties cannot be used in this area.

    Dynamic Drop-Downs in Create Workflow Job - Task

  10. Save and Close the task.
  11. Right-click your new task and select Queue Now.

You should receive an email with a URL link to the myBPAPlatformClosed myBPAPlatform is a web portal providing users secure access to manage their assigned Workflow Jobs. web portal. When logged in, you can see the contents of the drop-down:

Dynamic Drop-Downs in Create Workflow Job - Drop-Down Dynamic Drop-Downs in Create Workflow Job - Drop-Down Contents

From here, you can add the rest of your task that fulfils the required business process and performs the action of the chosen drop-down item — see How to Add a Create Workflow Job Task Step.