Performance Issue on Reference Qualifier
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-17-2024 12:58 AM - edited ā06-17-2024 01:06 AM
Hi
I am having an issue with performance of a Reference Qualifier and I was hoping some of you may have run across this before and knew of a way to fix it.
The issue:
On my Custom Table Field (Scoped Application ), I have the *Assigned To* field ( dependent on *Assignment Group* field )
Current Configuration :
Having a Simple reference Qualifier on user Table
Condition is -Role is ITIL
This field ( Assigned to ) is extended from task table, and a dictionary override is created for this field with override the reference qualifier
javascript:new RefQual().usersWithRole();
Current Problem is : This field ( Assigned to ) when selected to lagging for more seconds to Load than expected. making the pop up (magnifying glass) take 9-15 seconds to load once you click the icon.
Requirement is : We need to get the ITIL role users without LAG ( currently which is annoying the customer)
here is the Script Include code I am pasting
Script Include:
var RefQual = Class.create();
RefQual.prototype = {
initialize: function() {},
usersWithRole: function() {
var ids = {};
var users = "";
var gr = new GlideRecord('sys_user_has_role');
gr.addEncodedQuery("user.active=true^user.locked_out=false");
gr.query();
while (gr.next()) {
ids[gr.user + ""] = true;
}
for (i in ids) {
users += i + ',';
}
return 'sys_idIN' + users;
},
type: 'RefQual'
};
What changes are necessary to the dictionary entry in order to browser response time ?
Can any one suggest an urgent solution for this ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-17-2024 03:14 AM
You should be building an array in the Script Include, not an object, so you don't need the for loop. Your GlideRecord is returning, and adding the the array every user record with any role, so it's adding the user sys_id multiple times to the object/array, plus possibly some extra if there is someone with role(s) but not ITIL. You can see the results in a list view on the table with the encoded query manually applied. There will still be a lag if you have tens or maybe hundreds of thousands of users that you're pushing to the array, but this method will still be immensely faster.
var RefQual = Class.create();
RefQual.prototype = {
initialize: function() {},
usersWithRole: function() {
var ids = [];
var gr = new GlideRecord('sys_user_has_role');
gr.addEncodedQuery("user.active=true^user.locked_out=false^role.name=itil");
gr.query();
while (gr.next()) {
ids.push(gr.user.toString());
}
return 'sys_idIN' + users.join(',');
},
type: 'RefQual'
};