Performance issue on Advanced reference qualifier

Anil Karthik N
Tera Contributor

We have written one script include in global scope and calling it in Reference qualifier of Human resource:core scope.

We have one field referencing to user table in which we have reference qualifier to advanced from that we are calling script include. when we search its taking almost 3 to 4 minutes to get the users into the reference field.

 

Currently we have 60k records in the HR profile table.

 

below is my code:

 

getUsers: function() {

        var arr = [];

        var grManager = new GlideAggregate("sn_hr_core_profile");

        grManager.addEncodedQuery('u_employment_statusNOT LIKETerminated');

        grManager.query();

        while (grManager.next()) {

            arr.push(grManager.user.toString());

        }

       

        return 'sys_idIN' + arr;

       

    },

reference:

javascript: new scriptIncludeName().getUsers()

5 REPLIES 5

Swapna Abburi
Mega Sage
Mega Sage

Hi @Anil Karthik N 

Please use GlideRecord in your script include in place of GlideAggregate and try.

Hi @Swapna Abburi ,

We tried this but still facing the issue.

Ankur Bawiskar
Tera Patron
Tera Patron

@Anil Karthik N 

please use GlideRecord.

With 60k records it should not take much time.

getUsers: function() {

    var arr = [];
    var grManager = new GlideRecord("sn_hr_core_profile");
    grManager.addEncodedQuery('u_employment_statusNOT LIKETerminated');
    grManager.query();
    while (grManager.next()) {
        arr.push(grManager.user.toString());
    }
    return 'sys_idIN' + arr;
},

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

Hi @Ankur Bawiskar ,

 

Thanks for the code, but unfortunately, it didn't worked it is taking 3 to 4 minutes to load when I'm using GlideRecord.