Change the value of a field when a date has expired

paul_roberts
Kilo Expert

Hi All,

I'm looking at finding a way to update a field based on a date field's expiry.   It seems this may require some Scripting.

I'd like to be able to populate a read only field (u_change_window_exceeded_) to display the value of 'Yes' based on the expiry of a date field (end_date).

I'd also like to further automate a calculation to display the amount of time past the expiry (u_by_how_long_) if possible?

Thanks

Paul

10 REPLIES 10

Brad Tilton
ServiceNow Employee
ServiceNow Employee

Hi Paul,



For this you would need to run a scheduled job that runs daily and queries your table for any record with the end_date on that day. Then you can use the gliderecord to set the value of your field.


Hi Brad,



Thanks for your suggestion, I considered this approach however i thought it seemed a bit messy and the change guys would really like this information live when performing PIR which may or may not be after the scheduled job has run.   I wouldn't really want to add extra server load by performing this multiple times in a day either.



Is it not possible to script this?



Thanks


Paul


You just have to kick the script off from something. That can either be a scheduled job that runs periodically, or you could do it from a business rule, which would be when someone updates the record or an associated record.


Another alternative may be a Display Business Rule, but that would only work on form load and would not show up in the List.



One that keeps coming to mind for me is using gs.eventQueueScheduled() where you pass in your exceeded date.   You would have a lot of them in the system, but they would theoretically fire on your date and change the value without having to run a Scheduled Job.



-Chris