Need to send a notification to Author and KB owner for expiration of knowledge article?

Ramu6
Tera Contributor

Hi Al

 I have a requirement that  need to send  send a email notification to "Author ,KB owner and content owner" Whenever a knowledge article reaches 60 and  30 days before Valid to date?

If need to send warning notification exactly if valid to have due in 60 days and if due in 30 days also?

 

please help me to achieve to this

 

Thanks

Ramu

 

10 REPLIES 10

@Ramu6 

Try below code: which will give you articles having valid to from now at 30 days and 60 days

var gr = new GlideRecord('kb_knowledge');
gr.addEncodedQuery("valid_toRELATIVEGT@dayofweek@ahead@29^valid_toRELATIVELT@dayofweek@ahead@31^NQvalid_toRELATIVEGT@dayofweek@ahead@59^valid_toRELATIVELT@dayofweek@ahead@61");
gr.query();
while (gr.next()) {
gs.eventQueue('sn_hr_core.knowledge expiry', gr, gr.author, gr.kb_knowledge_base.owner);
}
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,Sushant Malsure

@sushantmalsure 

 

Thanks for the code, but this also not work, it pulls many records of previous year also

So i want that if valid to date is due in 60 days , need to send notification or if valid to date due in 30 days then also need to send notification, but not two notifications, need to achieve it in one notification?

 

Thanks

Ramu

Try below :

var gr = new GlideRecord('kb_knowledge');
gr.addEncodedQuery("valid_toRELATIVEGT@dayofweek@ahead@29^valid_toRELATIVELT@dayofweek@ahead@31^valid_to>javascript:gs.endOfToday()^NQvalid_toRELATIVEGT@dayofweek@ahead@59^valid_toRELATIVELT@dayofweek@ahead@61^valid_to>javascript:gs.endOfToday()");
gr.query();
while (gr.next()) {
gs.eventQueue('sn_hr_core.knowledge expiry', gr, gr.author, gr.kb_knowledge_base.owner);
}

 

If above didnt work then I must say try this filter manually on list layout to confirm the result set.

I see its working fine on my PDI, you may also want to validate if we are using correct field name  'valid_to' and same is used by knowledge articles.

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,Sushant Malsure

@sushantmalsure 

how do i test it on my list view, because it contain 

javascript:gs.endOfToday()

It should work in list view as well

 

https://<instanceName>.service-now.com/nav_to.do?uri=%2Fkb_knowledge_list.do%3Fsysparm_query%3Dvalid...


replace <instnaceName> with your instance

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,Sushant Malsure