- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-25-2016 08:58 AM
I am working on setting up a reminder notification that will be triggered when a scheduled job (that runs daily) finds today's date in a specific date field.
My first step is to get a field to have a date that is 30 days ahead of the "Valid_To" field. This field can be calculated by client script that updates whenever the record is saved. (So if someone changes the Valid_To field, this new field will change as well to a different date (now 30 days ahead of the updated Valid_To date).
Any ideas on how to set that script up? Or is there a better way to do this? I checked out the GlideSystem Date and Time Functions - ServiceNow Wiki and none of them really do this.
thanks,
Richelle
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-26-2016 07:55 AM
Hi Richelle
Apologies. I've checked the code again against a simple date field and does not work if the field has that format
Try this one.
var myValidTo = current.valid_to;
myValidTo = myValidTo.toString() + ' 00:00:00';
var gdt = new GlideDateTime(myValidTo);
gdt.addDays(30);
var gdtStr = gdt.toString();
var reminderOnStr = gdtStr.substring(8, 10) + '-' + gdtStr.slice(5,7) + '-' + gdtStr.substring(0, 4);
current.u_reminder_on = reminderOnStr;
Apparently you need to reformat the date as requested by the system.
Robo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-26-2016 09:12 AM
Yep. I've tried it a couple of different ways now...so far no luck. On Before, After, Async (with changing script starts)...at Client at Server...with the condition script and without it. Both Insert and Update Checked. Even tried it with just half the script (!current.valid_to.nil()).
The magic combo hasn't been found yet.
Richelle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-26-2016 09:18 AM
I got it. Under the "When to run," I have:
And I am using Run at: "client."
And under "Advanced," I have:
It works both on Insert (and Save) of new knowledge article and on Change of the Valid_to date in a knowledge article.
Thanks again for all of your help,
Richelle