We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

Issue with email notification for KB articles

dev_S
Tera Expert

Hi All,

 

I have a issue where I have a notification for KB articles which are going to expire in 10days the email should be triggered to the KB article author and in CC same Knowledge base managers or owners.

But in case the the notification is getting triggered to author but in CC KB managers or owners of different knowledge base.

I have tried but could not fix the issue If someone faced similar kind of issue or aware of the issue please let me know what might be the issue.
Thanks in advance!!

Below is the email script configured for the notification

(function runMailScript(current, template, email, email_action, event) {
    var ccSet = {};

    // Get the Article record from the current kb article
    var articleGR = new GlideRecord('kb_knowledge');

    articleGR.addQuery('sys_id', current.sys_id);
    articleGR.query();
    if (articleGR.next()) {

        // Get the Knowledge Base from the Article record
        var kbGR = new GlideRecord('kb_knowledge_base');
        if (kbGR.get(articleGR.kb_knowledge_base)) {

            // Add KB Owner to CC
            if (kbGR.owner) {
                var ownerGR = new GlideRecord('sys_user');
                if (ownerGR.get(kbGR.owner)) {
                    ccSet[ownerGR.email] = true;
                }
            }

            // Add KB Managers to CC
            var managerIds = kbGR.kb_managers.toString().split(',');
            for (var i = 0; i < managerIds.length; i++) {
                var mgrGR = new GlideRecord('sys_user');
                if (mgrGR.get(managerIds[i].trim())) {
                    ccSet[mgrGR.email] = true;
                }
            }
        }
    }
3 REPLIES 3

brianlan25
Kilo Patron

Instead of trying to script it why don't you just set the author and knowledge base owner on the "who will receive" tab in the notification in the user/group fields.

brianlan25_1-1783011578429.png

 

 

Hi @brianlan25 ,

 

I think if we directly add users instead of email script the individual emails would be triggered to author KB manager or KB owner but for me I need only one email should be triggered to Author and CC KB managers or owners.

 

Regards,

Dev

That notification works exactly as shown. It sends an email to both the Knowledge Article author and the Knowledge Base owner associated with the article.

The notification is triggered by a script that loops through all Knowledge Articles and sends a notification for each article. As a result, Knowledge Base owners may receive multiple notifications if they own a Knowledge Base containing multiple articles.

This is simply an example. In our current implementation, expiration notifications are sent only to the article author.