Auto Subscribe Knowledge Article to the updated Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2024 09:46 AM
If Author is becomes Inactive then we should need to update Author and make auto subscribe to the new author. I'm able to do the update Author when becomes Inactive. But When I'm trying to autoSubscribe to the new Author. I'm able to create a record in "sn_actsub_subobject_stream" table however cannot able to update Subscriber field. Basically, Subscriber is a reference field which refers to the LIve Profile table. In the Live Profile table we have a field called Document and field type is Docuement ID. Could someone please help me how to update it.
@Community Alums
Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2024 10:05 AM
To auto-subscribe a new author to a knowledge article after updating the author, follow these steps:
Update the Author: If the current author becomes inactive, update the author field on the knowledge article with the new author.
Create Subscription Record: In the sn_actsub_subobject_stream table, create a new record for the new author. You need to link the new author to a live profile, which requires setting the subscriber field.
Update Subscriber Field: To correctly update the subscriber field in the sn_actsub_subobject_stream table, you need the corresponding Live Profile record.
Here's a sample script to guide you:
var newAuthorSysId = '<new_author_sys_id>'; // The sys_id of the new author
var articleSysId = '<article_sys_id>'; // The sys_id of the knowledge article
// Find the Live Profile of the new author
var liveProfile = new GlideRecord('live_profile');
liveProfile.addQuery('document', newAuthorSysId);
liveProfile.addQuery('document_id', 'sys_user');
liveProfile.query();
if (liveProfile.next()) {
var subscriberId = liveProfile.getValue('sys_id');
// Create a new subscription record
var subscription = new GlideRecord('sn_actsub_subobject_stream');
subscription.initialize();
subscription.setValue('document', articleSysId); // The knowledge article sys_id
subscription.setValue('subscriber', subscriberId); // The sys_id of the live profile
subscription.setValue('document_table', 'kb_knowledge'); // The table name
subscription.insert();
} else {
gs.error("Live Profile not found for the new author.");
}
This script ensures that:
- The new author is linked to the appropriate Live Profile.
- A new subscription record is created for the new author in the sn_actsub_subobject_stream table.
Make sure to replace <new_author_sys_id> and <article_sys_id> with the appropriate sys_id values. Additionally, verify that you have the necessary permissions to access and modify these records.
…………………………………………........................................................................................
Mark it helpful 👍and Accept Solution ✅!! If this helps you to understand.
…………………………………………........................................................................................