How to send a single weekly email for each of our knowledge bases with knowledge items about to expire?

Bart Jan Bultma
Kilo Sage

As stated in the title.

We are using ServiceNow for a couple of years now, and our knowledge bases are expanding in content and number. We want to be updated on knowledge items that are getting close to their valid date (within 30 days) and have an automatic email sent to the owner of that knowledge base.

I could create a scheduled job and let it check all the knowledge items but that would send a notification for every item, like in this community post. Since we'll be having well over 100 items expiring early 2020, and we dont want to get that many emails every monday or so.

Can I open an email and add text to it, and send it when the scheduled job is finished? What we want is a single email to the owner/group of each knowledge base. In the email I want a list with knowledge numbers, short description and valid date, only of the knowledge items that will expire in the next 30 days.

1 ACCEPTED SOLUTION

matthew_magee1
Giga Guru

HI Bart,

We did something similar in our environment. We have 3 knowledge bases, each w/ 100-300 articles in each. We have 3 scheduled jobs, one for each knowledge base. First, you'll want to grab the URL of the filter by going to the kb_knowledge list and applying a filter like this:

find_real_file.png

 

Once you grab the URL (right click URL and select Copy URL, create a scheduled job. Here is what ours looks like:

find_real_file.png

 

Next create an event. Our event is called 'knowledge.articles.expiring.customerService'

Then create an email notification which is fired by an event

In the When to send tab, ensure the Advanced condition is 'answer = true;'

In the Who will receive, add your recipients

In the What it will contain, point to an email template.

In the template, in the Message HTML, you'll want to include a mail_script. The mail script will look like this:

(function runMailScript(current, template, email, email_action, event){

var article = new GlideRecord('kb_knowledge'); //create a query to retrieve knowledge articles

article.addEncodedQuery('workflow_state=published^valid_to<=javascript:gs.endOfNextMonth()^kb_knowledge_base=05ff44289f011200550bf7b6077fcfa3');

//only retrieve articles that are published and valid to next month and are assigned to knowledge base Customer Service

article.query();

while(article.next()){

template.print....

<add your content here>

}

}})(current, template,email, email_action,event);​

 

Hope this helps. Feel free to ask any questions.

 

Oh, you'll need to create a scheduled job for each knowledge  base and an event for each knowledge base and a notification for each knowledge base

 

 

 

 

 

View solution in original post

7 REPLIES 7

Thank you so much for this in depth answer! I'm pretty confident I can get it to work!

Josh Petrick
Kilo Sage

A simpler solution would be using scheduled reports.  The downside to that is you'd need to maintain them when the Knowledge Managers change, and that could be a lot to create/maintain if you have a large number of KB's.

I did not know about this, this is a much simpler solution that still gives the result I would want, thank you!