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:

  • Verify that they qualify to receive a card.

  • Submit a request for a card if they do qualify.

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-26.

Figure 5-26 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-27.

Figure 5-27 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-28.

Figure 5-28 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-29.

Figure 5-29 OnChange Event Properties

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

Figure 5-30 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-31). This method populates the value of the Candidates PickList control with the results of the query called EEOutsideLocalAreaCode (defined in Figure 5-27). It passes the value of the OfficeAreaCode text field as the query’s input parameter AreaCodeParam.

Figure 5-31 GetCandidates Event