I have written a PB on knowledge article which checks if knowledge article publication status is published then perform a simple chatter post. But what I see is the PB is not getting invoked even though it is active. As per real time scenario there is a approval process and after approval of knowledge article the article gets published using the approval process final approval action of publishing the knowledge article. Has anybody else faced the same problem when working with knowledge articles?
Kind of issue was reported here: approve article before publish
Knowledge Article object is very special object - you can not track changes of PublishStatus field in trigger/process builder. As workaround (not very good solution) -
- Remove "Publish" button from layout.
- Add a button using formula field. You can make this button prominent using any image. Place at very top-right in layout.
- This Formula field would redirect to a Visualforce page with record id as parameter.
On this page load, will publish the article using below code using PublishingService Class:
String articleId = 'Insert article ID';
In same transaction, we need to create chatter post using apex and redirect to article record page.