Presetting Default Values

When you design a process, one of your goals should be that no participant should need to enter data which the system can obtain automatically. In this task you will modify the Expense Report process to preset user attributes and provide a reasonable default for the date attribute.

The ExpenseReport process requires participants to input their name. Yet the process engine already knows the name of any participant because they had to log in, so this step should not be required.

In this task you will modify the ExpenseReport process so that the submittedBy participant is preset. You will also set up the process so that the submitDate attribute has a default value.

You will add an automatic activity to the Submit Report screenflow. In this activity, you will create a method to set the default values.

  1. In the Project Navigator, expand Processes and double-click on Submit Report. The design editor for the Submit Report screenflow appears.
  2. Insert an automatic activity (Automatic Activity icon 
				) between the Begin and Input Report activities. Name this activity Initialize Report.
  3. Right-click on the Initialize Report activity you just added, and click Main Task. The Main Task dialog box will appear.
  4. Set the Implementation Type drop-down list to Method.
  5. In the Method panel, click New. The New Process Method dialog box appears.
  6. Enter initializeReport in the Method Name field, and click OK.
  7. Back in the Main Task dialog box, click Edit. A code editor opens for the initializeReport method.
  8. In the editor, enter the following code exactly as shown:
    reportSf.submittedBy = Participant.id
    reportSf.submitDate = 'now'

    The first line uses the built-in Participant object, which is in the Fuego.Lib module.

  9. Save your changes and close the editor.

Your screenflow should now look like the following:

Figure 1. Submit Report screenflow with Initialize Report activity

You can follow these steps to in the Review Report screenflow, to preset the reviewedBy attribute.

To prevent the user from editing these preset values, you can also set the submittedBy field (which should have been named text0) to read-only in the SubmitReport presentation. To do this, set its Editable property to No. Do the same with the reviewedBy text field in the ReviewReport presentation.