how to send notification when kb article is going to expire in 15 days and 1 month

vamshi2
Tera Contributor

Hi Team,

please suggest how to configure notification which should trigger 1 month and 15 days before expiry date(valid to) 
notification should  trigger to contributor, approver manger and owner

FYI OOTB we have one month notification but we are not using it

8 REPLIES 8

AnkaRaoB
Kilo Guru

Hi @vamshi2 ,

 

 

Follow the below to steps to achieve your requirement

Step 1:

  • Table: kb_knowledge
  • Field used: valid_to
  • Articles must be in Published state
  • Expiry date must be populated

Step 2: Create Custom Event

Navigate to:
System Policy - Events - Registry

Create an event:

  • Name: kb.article.expiry.reminder
  • Table: kb_knowledge
  • Description: KB article expiry reminder

Step 3: Create Scheduled Script Execution

Navigate to:
System Definition - Scheduled Jobs - Scheduled Script Executions

Configure:

  • Run: Daily
  • Active: true

Script:

var reminderDays = [30, 15];

 

for (var i = 0; i < reminderDays.length; i++) {

    var days = reminderDays[i];

    var targetDate = new GlideDate();

    targetDate.addDays(days);

 

    var kb = new GlideRecord('kb_knowledge');

    kb.addQuery('valid_to', targetDate);

    kb.addQuery('workflow_state', 'published');

    kb.query();

 

    while (kb.next()) {

        gs.eventQueue(

            'kb.article.expiry.reminder',

            kb,

            days, // days before expiry

            ''

        );

    }

}

This single job handles both 30-day and 15-day reminders.

Step 4: Create Email Notification

Navigate to:
System Notification - Email - Notifications

Configure:

  • Table: kb_knowledge
  • When to send: Event is fired
  • Event name: kb.article.expiry.reminder

Step 5: Configure Recipients

Under Who will receive:

 Contributor

  • Add Field: author

 Owner

  • Add Field: owned_by

 Approver Manager

Use Scripted Recipient:

if (current.approver && current.approver.manager) {

    email.addAddress('to', current.approver.manager.email);

}

 

Subject:

KB Article ${number} Expiring in ${event.parm1} Days

 

Body:

 

The knowledge article "${short_description}" will expire in ${event.parm1} days.

Please review and extend the expiry date if required.

Expiry Date: ${valid_to}



If my response helped mark as helpful and accept the solution

 

vamshi2
Tera Contributor

HI @AnkaRaoB   Thanks for quick responce


in step 5 unable to add reception because knowledge (kb_knowledge) dont have respective fields like contributer, owner to add to notification

Thanks

Hi @vamshi2 ,

 

Please Use Scripted Recipients

Step 5 (Updated): Configure Recipients Using Script

Navigate to:
System Notification - Email -Notifications

Open your KB Article Expiry Reminder notification.

Scroll to Who will receive --Scripted recipients and use the script below.

Thanks,

AnkaRao

Ankur Bawiskar
Tera Patron

@vamshi2 

there is already OOTB scheduled job for this "Notification for Article Expiry Warning" which runs first day of each month for articles expiring in the next month.

Remember this is the system property "glide.knowman.enable_article_expiry_notification" should be true

Why you want something extra?

AnkurBawiskar_0-1769583494636.png

 

AnkurBawiskar_1-1769583504051.png

If you want custom then use flow designer

something like this using flow, but please enhance for days

AnkurBawiskar_2-1769583543864.png

 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader