Example: Use Checkbox element in a form dynamically

You can use the Checkbox element in the form to select multiple options in a form during bot runtime.

Prerequisites

You must:
  • Have a Bot Creator license.
  • Be assigned a custom role with create folder permission.
In this example, you create a process to register new employee details in the company database. The initial form contains basic information such as:
  • Name
  • ID
  • Date of birth
  • gender
  • location

Additionally, the initial form has only two options (San Jose and Tokyo) for the location field. You will make the location field dynamic during the request creation to be able to add a new location (India) for those employees whose ID falls within the 100 to 200 range.

Procedure

  1. Log in to the Control Room as a Bot Creator user.
  2. Create the initial form.
    1. On the left plane, select Automation.
    2. Select Create new > Form.
    3. Enter the form name as employee_register_initial_form.
    4. Enter the folder location as Bots\Employee Registration.
      To change where your form is stored, select Choose and follow the prompts.
    5. Select Create & edit.
    6. Add the following Elements and corresponding Element label in the form.
      Element Element label
      TextBox Full Name
      Number ID
      Date Date of Joining
      Dropdown Gender

      For the Dropdown element, enter Male, Female in the Enter list items separated by commas field.

    7. Select Save.
    8. Select Close.
  3. Create a second form.
    1. In the same folder location, select Create new > Form.
    2. Enter the form name as employee_location.
    3. Select Create & edit.
    4. Drag the Checkbox element into the form.
    5. Enter the name in the Element label field as Employee location.
    6. Click the plus icon in the Checkbox content field and add the locations San Jose and Tokyo.
    7. Select Save.
    8. Select Close.
  4. Create a new bot.
    1. In the same folder location, select Create new > Bot.
    2. Enter the bot name as dynamic_checkbox.
    3. Select Create & edit.
  5. Create the following variables:
    • emp_id: Number type; use as input
    • emp_location: List type, String subtype; use as output; click the plus and add two values San Jose and Tokyo
    • emp_dyn_location: String type, add the default value India

    The default values are San Jose and Tokyo however if the employee ID falls between 100 and 200, then location India is selected.

  6. Use the If action to configure the conditional statement.
    1. Double-click or drag the If action.
    2. Select Number from the Condition drop-down list.
    3. In the Source value field, insert the variable $emp_id$.
    4. Select Greater Than (>) as the Operator.
    5. Enter 100 in the Target value field.
    6. Click Add condition and select And.
    7. Select Number from the Condition drop-down list.
    8. In the Source value field, insert the variable $emp_id$.
    9. Select Less Than (<) as the Operator.
    10. Enter 200 in the Target value field.
    11. Click Save.
  7. Add the List package into the If container to insert the new location as per the defined condition.
    1. Drag the List > Add item action.
    2. In the List variable field, select the variable in which to add the list item emp_location.
    3. In the Item to be added field, select the variable that contains the value to add emp_dyn_location.
    4. Select Save.
    5. Select Close.
  8. Create a new process automation.
    1. In the same folder location, select Create new > Process. See Create a process automation in Process Composer.
    2. Enter the process automation name as employee_register.
    3. Select Create & edit.
    4. Select Start to add an initial form to the process automation.
    5. In the Select initial data form field, browse and select the initial form: employee_register_initial_form.
    6. Provide Request title as Employee Registration.
    7. Drag the Bot Task into the Process Composer from the Task field.
    8. In the Bot Task panel and Element name field, enter a name Location.
    9. Enter the Task name as Generate location.
    10. In the Select Task Bot field, browse and select the bot you created dynamic_checkbox.
    11. In the Input values field, select the input variable emp_id.
    12. Drag the Form Task into the Process Composer from the Task field.
    13. In the Form Task panel and Element name field, enter a name location_form.
    14. Enter the Task name Employee location form.
    15. In the Select form field, browse and select the form you created employee_location.
    16. Select Add button.
    17. Specify OK for the Button label and Primary for the Button style.
    18. Select the Feed data into form check box as Employee Location[CheckBoxGroup0].
      Set the two variables from the bot as output variables.
    19. In the List of options field, select the output variable $Location.output[emp_location]$.
    20. In the Default value field, select the output variable $Location.output[emp_dyn_location]$.
    21. Select Save.
    22. Select Close.
  9. Deploy the process automation.
    1. Select Run to create a request for the process automation.
    2. Enter the values for the initial form.
    3. Select Submit.
    The process automation deploys and if the employee ID falls between the values 100 to 200, then Employee location field will have a new option of India making this option dynamic. If the employee ID is not between the values 100 to 200, the Employee location field will have only two options, San Jose and Tokyo.