Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to get user records that are updated after a particular time in the previous day

pallavikavuluru
Kilo Contributor

Hi All,

                    We are trying to query the user records (from the sys_user table) that are updated after 03:30 EST yesterday by using glide record. This has to be done everyday to get the new users. Can anyone suggest any solutions to do that.

Thanks,

Pallavi

7 REPLIES 7

poyntzj
Kilo Sage

query against the sys_created_on field for new users


If you query against the sys_updated_on field, you will get updatews


Thanks for your reply julian



Yes, I am aware of querying on sys_updated_on to get updated records.


here am worrying about condition to specify "updated records after 3.30PM yesterday".


how to add this condition to query?



var user = new GlideRecord('sys_user');


user.addQuery('sys_updated_on',<<condition to get updated users after 3.30PM yesterday>>);



can you please guide me on filling place holder <<condition to get updated users after 3.30PM yesterday>>



Thanks,


Pallavi


poyntzj
Kilo Sage

I would use the GlideDateTime API and establish the date for yesterday - getDate() and addDaysUTC(-1)


I would then use this in an encoded query replacing the date part with the correct date



active=true^sys_created_on>javascript:gs.dateGenerate('2015-08-25','23:59:59')


Kalaiarasan Pus
Giga Sage

Try this. Define it in a script include and call it in the filter



var yesterdaysDate = gs.yesterday();


var yesterdayArrayVal = yesterdaysDate.toString().split(' ');


var formattedDate = new GlideDateTime(yesterdayArrayVal[0]+" "+'03:30:00');