5.7 Using DAL Queries in Forms

The Query objects defined in the directory abstraction layer let you predefine LDAP searches that you can then execute from a workflow form. The information in this section illustrates how you can define a query and use it in a form.

Suppose that you want to distribute calling cards to certain employees, but you only want to distribute calling cards to employees who work at home, and whose homes are located outside of the local office’s area code. You create a workflow form that allows the employee to:

On your form, you allow users to enter the area code of their own local office and based on that area code, review a list of users that qualify for a card. The runtime form is shown in Figure 5-34.

Figure 5-34 Sample Calling Card Request Form

The data in the Candidates Picklist control is populated from the results of a query that is defined as shown in Figure 5-35.

Figure 5-35 Calling Card Queries Definition

The query takes a single input parameter, AreaCodeParam, for the user-entered area code. The query then searches the User entity (in the idmsample-alh container) and returns the users whose telephone numbers do not start with the same value entered in the AreaCodeParam.

The form has an input field called OfficeAreaCode. It is the text field where the user enters the area code of the local office. The properties for OfficeAreaCode are show in Figure 5-36.

Figure 5-36 OfficeAreaCode Properties

Notice that the Text control defines an onchange event. The onchange event fires when the user tabs from the Text control. The onchange event fires the getCandidates custom event as shown in Figure 5-37.

Figure 5-37 OnChange Event Properties

The getCandidates event is defined as a property on the Candidates Picklist control.

Figure 5-38 Candidates PickList Properties

When the event is fired, the getCandidates event performs an action expression that calls the globalQuery() method (as shown in Figure 5-39). This method populates the value of the Candidates PickList control with the results of the query called EEOutsideLocalAreaCode (defined in Figure 5-35). It passes the value of the OfficeAreaCode text field as the query’s input parameter AreaCodeParam.

Figure 5-39 GetCandidates Event