Empty ResultSet when results should be present

Discussion created by Scott_Owens Employee on Sep 6, 2012
Latest reply on Sep 6, 2012 by epruneda
CA Process Automation Tech Tip by Scott Owens, Sr. Support Engineer, September 6th, 2012

When the first iteration of my operator returns no results, subsequent iterations continue to return no results even when there are results.

For example, you have an LDAP (can also occur with JDBC) operator running multiple times (such as within a loop) which tries to retrieve a user from LDAP with each iteration. For the first iteration, the user does not exist. The operator succeeds as it was able to connect, the query was able to run and it retrieved an empty ResultSet. The second iteration of that operator attempts to retrieve a user that does exist, but it still shows an empty ResultSet. This occurs because when the first run of the operator retrieves an empty ResultSet, it creates an empty String type array to store the results. The next iteration of the operator will retrieve information but it cannot overwrite a String type array with a ValueMap type Array which is needed to store the results from the second iteration.

The solution is to do a check in the operator’s post execution code for an empty ResultSet. If the ResultSet is empty, then the String array should be deleted so that the next iteration can build the ResultSet properly. Here is an example of this kind of post execution code:

if ((1 == Process[OpName].Result) && (Process[OpName].UserAccounts != undefined) && (0 == Process[OpName].UserAccounts.length)) {

Process.deleting = true;

deleteValueMapField(Process[OpName], "UserAccounts");

This works differently in 4.0 because 4.0 has the result datatype predefined. That means there won’t be a need to create an empty string type array for the operator since a ValueMap array variable for results will already be defined.