How can we put query to check if a particular field got updated after certain date/time?

Madhavi5
Giga Contributor

How can we put query to see if a particular field got updated after certain time?

I tried with:

var gr = newGlideRecord('table');

var currentdate = new GlideDateTime;

addEncodedQuery('u_applied_service.sys_updated_on>=' + currentdate);

u_applied_service is a text field. And this code is going to be used in a scheduled Job. This is not working and I see above code gets interpreted as - sys_idNOTValidNull in Logs. 

Anybody having idea on this?

8 REPLIES 8

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Any reason to keep the field "u_applied_service" as string and not date/time?

something like this when that field is date/time

gr.addQuery('u_applied_service', ">=", currentdate);

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi Ankur,

Its a text field,which is showing Service name. I need to run a JOB looking at if that value got updated after currentdate. 

I tried - 'u_applied_service.sys_updated_on', '>' , currentdate . This didn't work.

gr.addQuery('u_applied_service', ">=", currentdate);

This will not work as u_applied_service doesnt show any date/time value. 

Since you said "u_applied_service" holds string i.e. Service name so you cannot compare it with date time.

Are you storing somewhere when the field u_applied_service got changed?

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

No, i dont see anything such. In a table, how can we check if field got changed in scheduled job?I think, if I look at if that record got updated and then field value changed part. It can help me in achieving what I want to execute.