Notification for an Expiring Knowledge Article

cnharris1
Kilo Sage

Is there a way to send out a simple notification to the authors of a knowledge article to let them know that their article is about to expire? If so, how would I go about doing that?

1 ACCEPTED SOLUTION

Archana Reddy2
Tera Guru

Hi,

A Scheduled Job can do your work. Try with the below one.

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

Hope this helps!

Thanks,

Archana

View solution in original post

10 REPLIES 10

hey! so that script works perfect! but now they also asked if we could send it to the manager of the knowledge base. any suggestions on how i can accomplish that?

Hi Isak,

Basically the same code as above just that I added added KB owner to the second param called: "ka.kb_knowledge_base.owner.email"

You also have to modify the notification to send to both params.

Good luck!

 

//Running this Scheduled Job daily will send notification 7 days before the ExpiryDate

var ka = new GlideRecord('kb_knowledge');
//valid to on next week and workflow is not retired or outdated
ka.addEncodedQuery('valid_toONNext week@javascript:gs.beginningOfNextWeek()@javascript:gs.endOfNextWeek()^workflow_stateNOT INretired,outdated');
ka.query();

//use first and second params to determen where the e-mail should go
while(ka.next()){
	gs.eventQueue('my_expiring_knowledge_articles', ka, ka.author.email, ka.kb_knowledge_base.owner.email);
}

This worked perfectly!  I've been trying the original script above but nothing was sending. I decided to try your script and voila.  THANK YOU!

Hi Archana ,

 

I have a Requirement to send an email Notification to the Requester  when the end date of Contractor is getting close .

In detail :

In On-boarding REQUEST form , we have ( Start date & end date ).

If the Employee type is Contractor then we should enter the End date which is Mandatory .

I have entered  (start date = Jan 1 , 2019 )& (End Date is June 30 , 2019) while submitting an on boarding Request for user "XYZ"

Requester should get Email Notification that user ( "XYZ") account is coming up for expiration on May 30 , June 15 ( Nothing but 30 days & 15 Days before Expiration )

 

--------------------------------

created Scheduled job , event , notifications .

I have executed the scheduled job , but no results . 

 

Tried with your script , but not working .

 

we have declared end date in variable . 

"ob_contctrs_voul_interns_end_date" is the variable value.

-----------------------------------------------------------------------------------------------------

var ED = new GlideRecord('sc_req_item');
ED.query();
while(ED.next())
{
var exp = new GlideDateTime(ED.variables.ob_contctrs_voul_interns_end_date).getDate();
if(exp.addDaysUTC(-3)==new GlideDateTime().getDate())
{
gs.eventQueue('Alert check',ED,gs.getUser());
}
}

 

---------------------------------------------------------------------------------------------------------

Can you please provide solution for this .

Thanks

NR.

cnharris1
Kilo Sage

Thanks Archana, I had to tweak the script but it worked perfectly.