Script update of KBA uses "new article created" notification instead of "revised article"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2023 01:51 PM
Hi,
Looking at community posts I was able to use a business rule script to generate knowledge articles. What I notice though is that regardless of whether the knowledge article is created or updated, a knowledge base subscriber receives a "new article created" email notification.
The article is properly created (and a "new article created" notification is received as expected), and the article is properly updated (with version numbers incrementing and revision dates showing in the article itself) but the notification is still a "new article created" showing the original creator/date when the article was created.
When I create/publish, checkout/update/publish manually (by hand) then I get the notifications (new article versus revised article) as expected.
Specifically the code for creating the knowledge article looks like below using the .insert() method:
// Create the new article in draft state using the .insert() method.
var gr_article = new GlideRecord('kb_knowledge');
…code to populate the record fields for gr_article object...
gr_article.workflow_state = 'draft';
gr_article.insert();
// Update the new article to published state.
and the code to update the article looks like below using the .update() method:
// Get the article record using the sysid which we figured out before we got here.
var gr_kba = new GlideRecord('kb_knowledge');
gr_kba.get( knowledge article sysid );
// Change the article state to draft from published. Maybe this is the issue?
gr_kba.workflow_state = 'draft';
gr_kba.update();
…code to update record fields in gr_kba object…
// Now publish the update.
gr_kba.workflow_state = 'published';
gr_kba.update();
Maybe I shouldn't be resetting the state to 'draft' if it has already been published? Or is there something else that needs to trigger the "revise article" notification flow?
Regards,
Henry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2023 08:33 AM
check your sent notification's condition and modify it to NOT send it when State Changes FROM Published TO Draft.
Anyway this kind of code to update KB-s like this with BRs very not recommended. Use workflows instead
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2023 07:28 AM
Hi,
Thanks a lot for responding. I'll check out the notification conditions and see if I can discern anything more. In my case I was looking to generate knowledge articles based on specific fields from security incident tickets as fields get updated. I did see some discussions posted for this scenario (with incidents) so was using that as a guide but didn't see anything similar on how to achieve this with workflows.
Regards,
Henry