Using an Enumeration to Specify Choice Values

When an attribute is defined using an enumeration type, the default form will use an option list to edit that value, with the values of the enumeration presented as the choices.

Procedure

  1. Click the tab for the business object model editor.
  2. Click once on the GenericClaim class to select it. The buttons for adding an attribute or operation will pop up. Click the red button to add an attribute.
  3. Name the new attribute vehicleType.

    The attribute is created with the default data type of Text. But for this value, we don’t want the user to simply type free-form text into a text field to choose a type of vehicle. Instead, we want to present the user with a fixed set of vehicle types from which to choose. In the remainder of this tutorial task, we will create an enumeration and use it to redefine the data type of the vehicleType attribute.

  4. Click Enumeration in the Elements section of the Palette, and click inside the claim package to create the enumeration.
  5. Initially, the name field of the enumeration is selected. Rename the enumeration by typing VehicleType. (If the name field is not selected, click once on the default name, Enumeration, and press F2. Then type VehicleType.)
  6. When the enumeration is selected, a button will appear above the enumeration for adding an enumeration literal. Click the button and an enumeration literal will be added to the enumeration. The text for an enumeration is highlighted when it is first created, so you can begin immediatley to type the name. Give the first enumeration literal the name CAR.
  7. In the same manner, add three more enumeration literals, one called TRUCK, another called VAN, and a third called MOTORCYCLE.
  8. In the GenericClaim class, click vehicleType. Look below at the General tab of the Properties view for the vehicleType attribute. Notice that the type is currently the default type of Text. Click the ellipsis icon to open the Select Type dialog. Click VehicleType and click OK.
  9. Save the business object model.
  10. Preview the form to see the result. To do this, click the tab for the Business Process Editor in the editor view to see the Notification of claim business process. Right-click the Record no-fault claim details user task and click Form > Preview.
  11. The vehicleType enumeration control is now displayed on the form. Clicking the down arrow opens the list of choices. Notice that (unset) is one of the choices. This is because the control is optional, basedon its default multiplicity value of 0..1. If you set the multiplicity to 1, the control would be required, and the (unset) item would not appear among the choices.
  12. Return to the business object model and click the vehicleType attribute within the GenericClaim class. In the General tab of the Properties view, change the multiplicity from 0..1 to 1.
  13. Preview the form again in the Business Process Editor view. You will see that unset no longer appears in the list of choices, and there is now an asterisk next to the vehicleType control. Once a choice is made, the user’s only option now is to make a different choice—it is no longer possible to unset the vehicle type control so that it has no value.