We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

What is the max limit character for add query

Jyotshna_M
ServiceNow Employee

We currently filtering out the sys_emails which are inactive since last few days and closing them using schedule job with the below code

var interactionGr = new GlideRecord('interaction');
interactionGr.addQuery("active" , true);
interactionGr.addQuery("type" , "Email");
interactionGr.addQuery("sys_updated_on" , '<' , inactiveTimeout);
interactionGr.query();
var interactionIds = [];
while(interactionGr.next())
interactionIds.push(interactionGr.getValue("sys_id"));

var emailGr = new GlideAggregate("sys_email");
emailGr.addQuery("target_table", "interaction");
emailGr.addQuery("type","received");
emailGr.addQuery("instance" , 'IN', interactionIds.join(','));
emailGr.addAggregate('MAX', 'sys_updated_on');
emailGr.groupBy("instance");
emailGr.query();


Considering the huge interactions created , wanted to check what is the maximum length of query string to hold the list of sys_id's . And also if we wanted to process this in batch what should be the ideal length of each batch?
2 REPLIES 2

Sandeep Rajput
Tera Patron

@Jyotshna_M According to my knowledge the maximum length of query string is 4096 characters. Also, there is no way to adjust this limit.

Any document regarding this would also help