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

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Can you share your full code. This isn't it I assume?

Do see some incorrect parts already that you need to fix:

var gr = newGlideRecord('table');

> Space missing between new and GlideRecord
> which table?

var currentdate = new GlideDateTime;

> () missing

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

> addEncodedQuery belongs to? gr. I guess? Please fix this

You are mentioning, u_applied_service is a text field. Then you can't dotwalk like:
u_applied_service.sys_updated_on

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020, 2021 ServiceNow Community MVP
2020, 2021 ServiceNow Developer MVP

---

LinkedIn
Community article, blog, video list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Hi Mark,

Things that you mentioned are of no concern. I didn't wrote exact code here. I was just showing how I am trying to achieve. Do you have any idea how we can write query to check if certain fields got updated after a certain date/time?

Thanks!

Please share your real code then.

And see my other remark: why script at all? What you are describing, can be achieved with Flow Designer and zero code.

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020, 2021 ServiceNow Community MVP
2020, 2021 ServiceNow Developer MVP

---

LinkedIn
Community article, blog, video list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Mark Roethof
Tera Patron
Tera Patron

And ofcourse the important question... why script?

Why not going for a Scheduled Flow, looking at what you are after: zero code needed.

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020, 2021 ServiceNow Community MVP
2020, 2021 ServiceNow Developer MVP

---

LinkedIn
Community article, blog, video list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn