Scheduled Recurring Tasks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2011 02:28 AM
I have a requirement to create recurring future tasks for a client. I can use scheduled templates to create the records, but have two issues that I hope someone can help with.
1) How to set a glide_date field with a future repeating date within the template (gs.daysAgo(-x)) doesn't work.
2) How to schedule the recurrence for a specific weekday in the month (e.g. First Monday of every month)
Would appreciate any help from anyone who has created something similar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2011 10:26 AM
For #2, the following might work (I haven't tested it yet):
1) Create a schedule that only has Mondays in it.
2) In your scheduled job script a condition that looks for it to be within that schedule and that the day of the month is <=7.
//Grab the correct schedule
var schedRec = new GlideRecord('cmn_schedule');
schedRec.get('name', '<your Monday schedule>');
var sched = new Packages.com.glide.schedules.Schedule(schedRec.sys_id);
// Use isInSchedule to see if run time is in the schedule's time (basically a Monday) then see if that Monday is the 7th or // less day in the month.
var answer = (sched.isInSchedule(new GlideDateTime()) && (now.getMonth() >=7));
I think that will work, but as I mentioned, haven't tested completely. I will think on the first question, but am not entirely sure I understand what is being asked. Are you looking for a way to generate a date in the future?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2011 11:01 AM
Thanks for your feedback Jacob, I'll try your schedule idea.
You are correct about the template date, I have a duedate (glide_date) field on the form which I'd like to set to a future date every time the template is applied (or scheduled).
I'd like to be able to set the future date to be relative to the date the template was applied (ie. by using javascript:gs.daysAgo(-x) as the duedate value in the template), unfortunately the only gs function that seems to work and puts the date in the field in the correct format is gs.now().. no use when I want to be able to set a duedate in the future.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2011 11:48 AM
There are a set of functions that allow for time manipulation in the manner you are working towards. Take a look at the following: http://wiki.service-now.com/index.php?title=Modify_a_GlideDateTime_field_value. I think this is what you are looking for.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-17-2011 04:12 AM
Thanks Jacob, I tried using .addDays already but couldn't get it to work within the template.