Notification for an Expiring Knowledge Article
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2019 05:06 AM
Hi I would like to send an automatic message to the author 14 days before his article expires.
I've already found a script, but I don't really know how to use it and what event to create.
https://community.servicenow.com/community?id=community_question&sys_id=9778cb39db7adb4067a72926ca961999
Are there other and easier methods to solve this?
var ka = new GlideRecord('kb_knowledge');
ka.query();
while(ka.next())
{
var exp = new GlideDateTime(ka.exp_date).getDate(); //Considered exp_date as Article Expiry Date
if(exp.addDaysUTC(7)==new GlideDateTime().getDate())
{
gs.eventQueue('your_event_name',ka,gs.getUser()); //Include the recepients you require
}
}
//Running this Scheduled Job daily will send notification 7 days before the ExpiryDate
//You have to create a notification to be triggered when 'your_event_name' is triggered
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2019 06:02 AM
See my edit above about the gs.getuser line in the script you have.
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2019 06:17 AM
Hello, thank you very much for your answer. I've tried it before, but it doesn't trigger the event at all. What else do I have to set in the event, besides the name?
I have also changed the getuser to ka.author.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2019 06:27 AM
Are you checking your event log to see that it's not working? When you set the scheduled job, it will only run at the day/time you set, unless you click "execute now"...so you'd need to provide more information as to the steps you're taking...and perhaps paste the exact script you have there...here...so we can see what you've done thus far. As of right now, all we're getting back from you is that it's not working. Please give more information.
Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2019 06:36 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2019 07:20 AM
In the event line in your script in the scheduled job, you need to have ka.author, just like I mentioned above. Not ka.author().
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!