Reference qualifier conditons - show only records in capital letters

kandulek
Tera Contributor

Hi All,

 

We have the following reference qualifier condition in the reference type variable:

nameSTARTSWITHCORE

kandulek_0-1753706590799.png

 

It dislays results in both upper and lower case letters.

 

Is there a way to filter the results to show only the ones that start with CORE in the upper case letters?

 

Thank you in advance for any hints.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@kandulek 

STARTSWITH in ServiceNow is case insensitive so it will show lower and upper case both.

you will have to use script for this

Script Include:

var RefUtils = Class.create();
RefUtils.prototype = {
    initialize: function() {},

    getRecords: function() {
        var answer = '';
        var gr = new GlideRecord('YOUR_TABLE');
        gr.addQuery('name', 'STARTSWITH', 'CORE');
        gr.query();
        var ids = [];
        while (gr.next()) {
            // Ensure exact case match at runtime
            if (gr.name.toString().startsWith('CORE')) {
                ids.push(gr.sys_id.toString());
            }
        }
        if (ids.length > 0) {
            answer = 'sys_idIN' + ids.join(',');
        } else {
            answer = 'sys_idIN';
        }
        return answer;
    },

    type: 'RefUtils'
};

AnkurBawiskar_0-1753707472611.png

 

Then call it like this

javascript: new RefUtils().getRecords();

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

3 REPLIES 3

palanikumar
Giga Sage

Hi @kandulek ,

 

Reference qualifier condition is case insensitive by default.

You can create a script include based if the number of records returned is not huge. This script include can checks the case and return the sys_id as coma separated value.  

 

Thank you,
Palani

Ankur Bawiskar
Tera Patron
Tera Patron

@kandulek 

STARTSWITH in ServiceNow is case insensitive so it will show lower and upper case both.

you will have to use script for this

Script Include:

var RefUtils = Class.create();
RefUtils.prototype = {
    initialize: function() {},

    getRecords: function() {
        var answer = '';
        var gr = new GlideRecord('YOUR_TABLE');
        gr.addQuery('name', 'STARTSWITH', 'CORE');
        gr.query();
        var ids = [];
        while (gr.next()) {
            // Ensure exact case match at runtime
            if (gr.name.toString().startsWith('CORE')) {
                ids.push(gr.sys_id.toString());
            }
        }
        if (ids.length > 0) {
            answer = 'sys_idIN' + ids.join(',');
        } else {
            answer = 'sys_idIN';
        }
        return answer;
    },

    type: 'RefUtils'
};

AnkurBawiskar_0-1753707472611.png

 

Then call it like this

javascript: new RefUtils().getRecords();

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

kandulek
Tera Contributor

Thank you both for your help!