ServiceNow should send the first email follow-up 30 days before the article's expiry date

sukanya kotni
Tera Contributor

 

To: Content Owning groups email, Knowledge Management Group DL ,Group manager. (If no group DL available, please send to all group members and group manager)

CC: Please include the members of XYZ group and add the support group’s SDL’s email. If support group begins with a word "KB" then include PQR group.

Subject: Reminder, KBA expires in 30 days. Review of (Insert KBA number) Owned by “ServiceNow support group name”.

 

Hello (Insert ServiceNow support group name),

 

Please review the Knowledge Article (Insert KBA number) at the earliest and share your response whether the content is valid on its current state or if it require updates. You can also confirm in case any knowledge article need to be retired.

 

Note: If no action is taken, this KBA will be expired on {KBA expiration date in MM/DD/YYYY format} and will no longer be available in the ServiceNow Knowledge Base.

 

 

 

2 ACCEPTED SOLUTIONS

Hi @sukanya kotni from where does the support grp field come? You can do like this below

var grp = current.support_group;

var grp = 'kb';
if(grp.indexOf('kb') > -1)
{

gs.info("KB group found);
// your logic here
}

else if(grp.indexOf('PQR') > -1)

{

gs.info("PQRgroup found);
// your logic here

}

 

to get date format use below logic

var date;
var format;
var kb = new GlideRecord('kb_knowledge');
kb.addQuery('sys_id','d22ce0b197987110df5db8a3f153af47'); // pass article sysid
kb.query();
while(kb.next())
{
date = kb.valid_to;
format = date.getByFormat("MM-dd-yyyy"); // getbyformat
gs.info(format);
}

Regards
Harish

View solution in original post

Hi @sukanya kotni If my answer has helped you. Please accept my solution.

Regards
Harish

View solution in original post

9 REPLIES 9

Chandresh Tiwa2
Mega Guru

Hi,

 

1. Create a event in Event Registry. Select table as kb_knowledge.

ChandreshTiwa2_0-1696585317883.png

 

2. Create a notification and call the event in When to send. For recipients create email script to add people in To and CC.

ChandreshTiwa2_1-1696585429833.png

 

ChandreshTiwa2_2-1696585594941.png

3. Create a scheduled job to run daily and check articles expiring after a month. Send email to author and other recipients.

var ob = new GlideRecord('kb_knowledge');
ob.addQuery('valid_to', '>=', gs.daysAgo(-30));
ob.addEncodedQuery('workflow_stateNOT INdraft,retired');
ob.query();
while(ob.next())
{
	gs.eventQueue('email.validity',ob);
}

ChandreshTiwa2_3-1696586158584.png

 

Please mark the answer as Helpful / Correct, if it helped.

Hi @Chandresh Tiwa2 ,

I tried above scheduled job but it is working. Here notification shouls send the email for when article expiry date before exact 30 days.

 

Thanks,

Sukanya

 

Harish KM
Kilo Patron
Kilo Patron

Hi @sukanya kotni you can create a schedule job which checks daily and create a event which triggers the Notification. In Notification you can specify who should receive the email

Example schedule job script

 

doit();function doit(){
var gr = new GlideRecord('kb_knowledge');
gr.addQuery("workflow_state", "published");
gr.addQuery("valid_to", "<=", gs.daysAgoStart(-30));//equal to 30 days
gr.query();
while (gr.next()){
gs.eventQueue("kb.expired20", gr, "", ""); // event to fire notification
}

Regards
Harish

Hi Harish,

Thanks for your response.

 

We have tried the below script. It is running today's expiry date. 

Please help me on email script for the Date format.

 

var ka = new GlideRecord('kb_knowledge');
ka.addQuery('valid_to', gs.daysAgo(-30));
ka.query();
while(ka.next())
{
var exp = new GlideDateTime(ka.valid_to).getDate(); //Considered valid_to as Article Expiry Date
gs.log("valid date : "+exp);
exp.addDays(0);
gs.eventQueueScheduled("kb.article.remainders", ka, """",exp);
ka.update();
}
 
Thanks,
Sukanya