6

Searching for NOT empty values in LMS

 2 years ago
source link: https://blogs.sap.com/2022/04/15/searching-for-not-empty-values-in-lms/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

search.jpg

Overview


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 % 
for multiple). 
enableSingleCharacterWildCard=true
enableMultipleCharacterWildCard=true

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:

matchOptionDefaults[OP_CONTAINS]=true

(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%20for%20a%20user

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.

[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]

Search Criteria
Email Contains … Description Results

bo%@sfdomain.com Email addresses that contain the letter “bo” (in that
sequence) followed by anything else, no matter how
many characters follow the initial sequence. [email protected]
[email protected]
[email protected]
[email protected]

b_bb%@sfdomain.com Email addresses that …

  • start with b
  • have exactly one character after the b
  • have two additional b’s after.
  • May have additional character after

[email protected]
[email protected]

[email protected] Email addresses that

  • Start with b
  • Have exactly 4 character after the initial b

[email protected]
[email protected]

Solution B: Add an Operator in the dropdown list


The second option, which may have been the more desirable, is also the most labor intensive solution. If we navigate to the following location:

System Admin » Configuration » Search Selectors » USER (for this particular example)

Edit this search selector. Scroll down until you find the criteria for Email Address. Add (copy & paste) these 4 lines of code.

criteria.EmailAddress.criterionUI.matchOptions.OP_NOTNULL.enabled=true
criteria.EmailAddress.criterionUI.matchOptions.OP_NOTNULL.order=7.0
criteria.EmailAddress.criterionUI.matchOptions.OP_NOTNULL.value=OP_NOTNULL
criteria.EmailAddress.criterionUI.matchOptions.OP_NOTNULL.label=label.IsNotEmpty

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.

ignoreBox.png

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!


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK