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

Combined Queries in ServiceNow

spgupta
Tera Contributor

How to write sysparm_query for the following condition?

FYI, I am using tables API 

(sys_updated_on == $time AND sys_id = $id) OR (sys_updated_on > $time)

5 REPLIES 5

Kieran Anson
Kilo Patron

Can you provide more information on your issue? 

 

sys_updated_on == $time should be a single equals sign

Hi Kieran

 

We want to paginate on the table using sys_updated_on parameter. 
Using sysparm_offset for pagination is not a good way, since deletes on the table will change offset indexing and can lead to records being skipped. And alone sys_updated_on is not a good option as well. 

Hence, we want to use both sys_updated_on and sys_id for pagination, using this condition:

(sys_updated_on = $time AND sys_id = $id) OR (sys_updated_on > $time)

This seems to differ to your original question. Can you explain in detail your issue and I can provide a more comprehensive answer 

@spgupta - If pagination needed via GlideRecord, then you may use "chooseWindow"

Sample

var in= new GlideRecord('incident');
in.orderByDesc('sys_updated_on');
in.chooseWindow(10, 20);
in.query();

while(in.next())

{

gs.log("Incident Number="+in.number)

}

 Thanks,

Narsing