Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Click on Images to Expand Them

Choices Expressions are used to create selection lists (dropdowns, radio button lists, or choice buttons) with dynamically changing values. That means the list of options will be different depending on some condition. This condition can be based on a value selected in another field; permissions of the user; account owner's age; the number of listed beneficiaries; etc.

In the example below, options for Risk Tolerance will be restricted by the user's answer to the Is Income Your Account Investment Objective? question. The question will be a Checkbox Selection field with two pre-defined choices. The Risk Tolerance will be a Single Selection field that uses Choices Expressions and is displayed as a list of Radio Buttons.

To create such a dynamic field, you need to:

  1. Create arrays that return the required data sets for the options that will be available for selection.

  2. Define a function that chooses one of the arrays depending on the defined condition.

  3. Create a Single Selection field with the "Use Choices Expression" setting selected.

  4. In the Choices Expression setting, call the predefined JavaScript function.

Step 1: Find Meta Field Names and Values.

This is important for mapping fields correctly to a PDF form.

1.1.

Rw ui steps macro
Rw step

Open a relevant document from a Client subfolder.

1.2. Click here to view

Rw step

Turn on Admin Mode, by clicking the cog icon.

Image Added
Image Removed1.3.
Rw step

Hover your mouse over a field to see the meta field name and corresponding value.

Meta Field Names and Values on a PDF form in Admin Mode

Step 2: Create a New Widget.

2.1.
Rw ui steps macro
Rw step

Proceed to Administration menu > Single Pane of Glass tile > Widgets tile.

2.2.
Rw step

Create a new Dynamic Wizard widget.

Step 3: Add a Load Action.

3.1.

Rw ui steps macro
Rw step

Open the Docupace Start editor.

3.2.
Rw step

Navigate to Wizard tab > Wizard Settings.

3.3.
Rw step

.In the onLoad actions section add new JS code.

First: This script first defines a dspSession object within the $scope of the wizard, which will keep all the temporary values during the session. This needs to be done only once within the wizard.

Second: Then it defines a getRiskToleranceOptions function that checks the value of a portfolioObjective passed to it (this would be a value selected by the user as a checkbox).

Tip

Results:

A. If there is no value selected, then this dropdown will also be empty.

B. If there is a value selected, then it checks whether the value matches one of the cases defined here, and shows the corresponding options:

  • for value '1' (selected) options

    • 'Low' and

    • 'Moderate'

  • for value '3' (deselected) all options

    • 'Low'

    • 'Moderate',

    • 'Speculation' and

    • 'High Risk'

Note

Attention: Because the values are "hard-coded" in this script, make sure they match exactly those values, which will be available to the user in the Investment Objective field.

In this case, they are choices defined directly in the Investment Objectives field.

Field

Value

Virtual file name

dynamicDropdowns.js

Code

Code Block
languagejs
$scope.dspSession = {}

$scope.dspSession.getRiskToleranceOptions = 
 function getRiskToleranceOptions(portfolioObjective) {
  if (portfolioObjective == null) {
    return []
  }

  switch (portfolioObjective) {
    case '1': //'Income'
      return [
        { value: '1', label: 'Low' },
        { value: '2', label: 'Moderate' }
      ]
      break
    case '3':  //'All Options'
      return [
        { value: '1', label: 'Low' },
        { value: '2', label: 'Moderate' },
        { value: '4', label: 'Speculation' },
        { value: '3', label: 'High Risk' }
      ]
      break
    default:
      return []
  }
}

Step 4: Create a New Page

4.1.

Rw ui steps macro
Rw step

Open the Pages tab.

4.2.
Rw step

Create a new page.

4.3.
Rw step

Add two fields to it.

Step 5: Add a Checkbox Section Field.

5.1. Open

title
Rw ui steps macro

o tOpen Add Field panel.

5.2.
Rw step

Add a Checkbox Section field to the page.

Note: This first field will ask the user to answer the question: Is Income Your Account Investment Objective?

5.3.

Rw step

Enter the following values for the field settings:

Adding a Checkbox Section field

Expand

field

values.Field

Value

Field Label

Is Income Your Account Investment Objective?

This is the name of the field that is displayed to the user.

Meta Field Name

Owner1.PortfolioObj

This is the unique name for the data held within the field as it will be referenced by other JavaScript code in the widget (the Choices Expressions function defined earlier) and mapped to respective fields in PDF forms.

Initial value

"3"

As "3" is the value for a deselected checkbox, then the checkbox will initially be

deselect

deselected, but

it's

its value will not be NULL.

Value for Checked

1

This value will map to the corresponding "value" attributes of the meta field name in the PDF form

,

if the checkbox is selected.

Value for Not Checked

3

This value will map to the corresponding "value" attributes of the meta field name in the PDF form

,

if the checkbox is not selected.

Step 6: Add a Single Selection Field.

6.1.

titleClick here to view
Rw ui steps macro
Rw step

Open Add Field panel.

6.2.

Rw step

Add a Single Selection field to the page.

Note: This second field will show Risk Tolerance options, applicable to the selected investment objective.

6.3.

Rw step

Enter the following values for the field settings:

Adding a Single Selection field

Expand

field

values.

Field

Value

Field Label

Risk Tolerance

This is the name of the field that is displayed above the list of options.

Use label as placeholder

Selected

Meta Field Name

Owner1.RiskTolerance

This is the unique name for the data held within the field as it will be mapped to respective fields in PDF forms.

Display Type

Radio List

The list of options will be displayed as radio buttons.

Layout

Horizontal

The radio buttons will be displayed horizontally.

Use choices expression

Selected

Choices expression

This will call the getRiskToleranceOptions function and pass to it the value selected in the Owner1.PortfolioObj field.

Tip

Alternate: If your fields are located within a Field Group, then use 'model.parent.value' instead of 'startingPointData' to refer the checkbox field.

Step 7: Apply Your Changes.

7.1
Rw ui steps macro
Rw step

Click the Apply button

in

at the bottom of the screen to close the Widget Design Screen and apply changes.

7.2.

Rw step

Click the Save button

in

at the top of the Widget Details Screen to save these changes.

Step 8: Test Your Widget.

Test the widget. For example, by selecting 'Is Income Your Account Investment Objective?' option in the wizard. Available options for the Risk Tolerance field should be reduced to two options 'Low' and 'Moderate'.

List of options changes based on a checkbox selection