Subscribe a customer contact to Knowledge Article using script - is this possible?

mgilbert42
Tera Expert

Hello SN community,

 

We have a need to subscribe customer contacts to KB articles created off of a case.  We already have a UI action in place that creates a KB article from the case record.  I was hoping there was a delivered script include that would expose some helpful functionality for this need but the closest I got to anything that approached this was in 

global.KnowledgeAjaxSNC but it only has subscribe/unsubscribe functions for the current user authenticated to the system.
 
Does anyone have experience trying to implement this functionality?  In summary, this is the goal:
 
1 - A case is created with a customer contact
2 - our internal staff support agent creates a knowledge article off of the case
3 - the customer contact linked with the case is automatically subscribed to the knowledge article created (ideally during the UI action script that creates the article)
 
Thank you for your time in reading this!
3 REPLIES 3

Akash4
Kilo Sage
Kilo Sage

Hello,

You can update the existing UI Action to add the subscription functionality. Once the KB is inserted via UI Action, store the insert in a variable and start GlideRecord for kb_subscribe with its article as KBsysID, user as customer_contact from Case. Example code looks like below:

//---previous Code till here----
var kbSysId = kbGR.insert();
    if (kbSysId) {
        var subscriptionGR = new GlideRecord('kb_subscribe');
        subscriptionGR.initialize();
        subscriptionGR.article = kbSysId;
        subscriptionGR.user = caseGR.customer_contact; //caseGR is current as UIAction is on 'sn_customerservice_case'
        subscriptionGR.insert(); //Customer contact subscribed to KB article
    }
action.setRedirectURL(current); //dont forget to add this incase UIAction clicking person needs Case view

Hope this helps!

Regards, Akash

Please mark it as helpful👍 or Accept Solution✔️ based on answering your query.

Regards, Akash
If my response proves useful, please mark it "Accept as Solution" and "Helpful". This action benefits both the community and me.

Hello Akash, thank you for the reply!  Unfortunately we do not have the kb_subscribe table in our instances.  I'm not able to find documentation for this table, do you have a reference to any docs or developer pages?  Thanks!

I haven't worked with the table directly, but I believe you want to use the sn_actsub_subobject_stream table.