While I was conducting a workshop on implementing custom search selectors, one of the participants asked if it was possible to search for users where email address, for example, is NOT Empty? (you'll notice that the capacity to search on emails that ARE empty is in the product already).
Answer: Yes, absolutely! There are two ways in which we can do this. The first, and simplest
option, is to user a wildcard with the “Contains” operator. The second, and more time consuming
option, is to add a new operator to the specific field.
In this blog, we will explore these two solutions to the question raised.
Solution A: Use Wildcards
First, we need to agree that searching for something that is not empty should (and will) yield the same result as searching for something that contains any value. Simply rephrased, “Not Empty" is synonymous with "Contains something”. If we can agree to that, proceed to the next steps.
Let’s make sure wildcards are enabled in your instance. Navigate to the Search properties page.
System Admin » Configuration » System Configuration » SEARCH
Scroll down until you locate the following lines:
# This configuration allows the enabling of wildcard characters to be used in searches (_ for single and %
A default installation of LMS will have both of those settings set to false. In order for this solution to work, you must set enableSingleCharacterWildCard=true. You may opt to also set the enableMultipleCharacterWildCard=true as well, but it is not required for this solution. If these settings are already set to true, you can continue with the following steps.
*NOTE: Using Wildcards for searching is a fairly common request during implementation, so it is entirely possible that your implementation consultant (SuccessFactors, or 3rd Party) enabled these prior to your original go-live date.
TIP: While you are here on this SEARCH properties page, you may also want to consider adding this line:
(Its unrelated to the solution here, but this will make all your search selectors default to "Contains" instead of "Starts with")
Return to your User Search screen. The goal here is to search for all users who have something in the email address field. Anything. Literally not empty. Now that wildcards have been enabled, we can search for users whose email address “contains _”, or “contains %”. Both of these search criteria will work.
Searching for a user
Searching using Wildcards by example
Let’s use the following list of email addresses as our users. We can use the “Contains” operator with our newly implemented wildcards.
If you are using this job aid to modify a different field, you’ll need to adjust the highlighted code to the field name you are modifying. The remaining code should remain the same. When done, click “Apply Changes”.
Searching using “is not empty” by example
Now let’s go back to the Users Search screen. When you add Email Address to the Search Criteria, you’ll see that there is a new operator “is not empty”. You can ignore the box that now appears. Leave it blank if you are using this new operator.
As you can imagine, this solution would be specific to the Search Selector type (in this case, USER), and specific to the field you are searching (EMAIL ADDRESS). If you wanted to implement this solution in all fields, you would have to repeat the above process for all fields, in all search selectors.
For this reason, you may want to consider Solution A as the more viable option!