When you design a process, one of your goals should be that no
participant should need to enter data that 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.
However, because the process engine already knows the name of any participant from the log-in process, this step should not be required.
In this task you modify the ExpenseReport process so that the
submittedBy participant is preset and the
submitDate attribute has a default value.
You add an automatic activity to the Submit Report screenflow. In
this activity, you create a method to set the default values.
- In the
Project Navigator, expand Processes and
double-click on Submit Report.
The design editor for the Submit Report screenflow appears.
- Insert an automatic activity (
) between the Begin and Input Report activities. Name
this activity
Initialize Report.
- Right-click on the Initialize Report activity you just added,
and click
Main Task.
The
Main Task dialog appears.
- Set the
Implementation Type list to
Method.
- In the
Method panel, click
New.
The
New Process Method dialog box appears.
- Accept the default name offered,
initializeReport, in the
Method Name field, and click
OK.
- Back in the
Main Task dialog box, click
Edit.
A code editor opens for the
initializeReport method.
- 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.
- 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. You can do the same with the
reviewedBy text field in the ReviewReport
presentation.