Change the value of a field when a date has expired
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2015 04:46 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2015 01:09 AM
Thanks Chris - will have a look at this to see if it satisfies their requirements.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2015 01:08 AM
Thanks again Brad - i'll have a dabble and see if i can figure it out.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2015 09:50 AM
Hi Paul,
I think Scheduled job should be used here.I had a similar requirement to change the Incident state to Active from Pending when the Pending expiration date passed.
I have written a Scheduled job with below config
Run--> Periodically
Repeat Interval --> 5 mins
Run this script:
var gr = new GlideRecord("incident");
gr.addQuery('state', 4); // state is Pending
gr.query();
while(gr.next())
{
var diff = gs.dateDiff(gs.nowDateTime(), gr.u_pending_expiration.getDisplayValue(), true);
if(diff<0){
gr.state = 2; // state set to Active
gr.work_notes = "Pending Expiration time has passed";
gr.update();
}
}
Modify this script according to your requirement.
Hope this helps
Suraj Chauhan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2015 01:10 AM
Thanks Suraj - this is really helpful. Thanks for the Script. I'll have a go with it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2015 09:33 AM
Paul,
I've used inactivity monitors and conditions on a due date field in the past to do something similar. The inactivity monitor creates an event that I used to craft an email and separately created a script action to update the record. This does not sound like the exact solution for you as I was looking into inactivity and you may only be concerned with past due (regardless of activity) but the set up using the script actions and a crafted event may be a useful alternative to scheduled jobs. You will still have to trigger the event creation somehow though.
Script Actions - ServiceNow Wiki