Need to send a notification to Author and KB owner for expiration of knowledge article?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2023 02:29 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2023 04:25 AM
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);
}
Regards,Sushant Malsure
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2023 06:30 AM - edited 10-27-2023 06:36 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2023 06:39 AM - edited 10-27-2023 06:43 AM
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.
Regards,Sushant Malsure
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2023 09:43 AM
how do i test it on my list view, because it contain
javascript:gs.endOfToday()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2023 05:03 AM
It should work in list view as well
replace <instnaceName> with your instance
Regards,Sushant Malsure