Adding Search Filter Functionality to the Workflow


There have been requests lately, working in the field for the capability to search large result sets or drop down lists using a Search Filter within the request form of the workflow. The business requirement is that the user accessing the request form needs to have a search filter which can be used to narrow down the result of a field within the same request form with multiple entries which are not very convenient to scroll.

Consider the following scenario.

A workflow is in place to allow the users to select a group to request for group membership. A field (call it “Available Groups”) on a request form has logic to preload all the groups (displayed by group names ) to which the user can request group membership. Now to select the group the user wants to be a member of, there is a possibility that the user will have to scroll all the way down the list to get to the desired group.

The Search Filter will be of good value in the above case. A field (call it “Search Filter”) can be added to the request form. The Search Filter field will allow the user to enter a search string which will then be used to lookup the groups loaded in the Available Groups field which match(partially or wholly) the string entered in the Search Filter field.

Based on the matching pattern, the Available Groups field will be narrowed down to a much smaller list from which the user can select the desired group to request the group membership.

As seen from the example above, the Search Filter is a generic implementation which can be extended and used within any scenario where there is a need to narrow down the results of an existing result set or list and thus provide enhanced user interface experience.

The following code snippet illustrates a basic search filter implementation:


1. The search filter field name is called "searchFilter"

2. The Available Groups list is populated in a field called "availableGroups"


The code below will be added as an event(call it "loadRestrictedGroups") to the "availableGroups" field and will be called from the "searchFilter" field using the method field.fireEvent("loadRestrictedGroups") on a "onBlur" event or any other event can also be used based on the requirement. This will result in the user "tabbing" out of the "searchFilter" after entering the search string and the "availableGroups" list will be refreshed and loaded with the matching results based on the search criteria.

if (form.getValue("availableGroups") != null) 

var fil = form.getValue("searchFilter");

if (fil.length > 0) {
fil = '*' fil '*';

try {
var res = IDVault.globalQuery(null, "GetAvailableGroupsbasedonMatchingPattern", {"str1":fil});

} catch(e){};

var actualValue = [];
var actualdn = [];

for (var i=0; i<res[0].length; i ) {

var dn =res[0][i].toString();

var str = IDVault.get(null, dn, 'group', 'groupName').toString();

if((actualValue.length > 0))


field.setValues(actualdn, actualValue);

//End code

As seen above, the "GetAvailableGroupsbasedonMatchingPattern" query is used with the "search criteria string" as one of the parameters. The query returns a result of the group DN's within the "availableGroups" list which match the search string.

The rest of the code basically fetches the group name for each group DN returned(since the availableGroups field displays group names to the user) and populates the availableGroups field with the group name as the display and the group DN as the value at the backend.

This implementation can be extended to any form field which requires a specific subset from the large list of results.


How To-Best Practice
Comment List