function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Publish and unpublish Knowledge Articles via the API



Is there a way to programmatically publish or unpublish a Knowledge Article?  I don't see anything in the API documentation where this is possible.  If not, is this planned for a future release?






you are correct the API allows only creating "draft" articles, and there is currently no possibility for updating an article, publishing it, unpublishing it or archiving it in a programmatic way.

it is on our plans to deliver those capabilities, but it is still a couple of releases away.





Hi Etienne, Grant from Stone Cobra here. I noticed with the Summer 2011 release that the PublishStatus can now be set programatically. Articles created this way are funny article management, they show up without any associated actions (all you can do is Preview). If I dig deeper, will I find I'm just missing a few relationships/fields here and there, and if I fill them out, I'll be able to programatically publish?


Interesting....the semi-published article is indexable and find-able by SOSL. None of the missing publish date fields are writeable though, so that may stop me dead in my tracks.




Can you precise how you set the PublishStatus because you should not be able? 




Sure Francois. I'm using schema describe calls to fetch all the field names in Apex and populating a field set with them, then in a Visualforce component, I gather user input using the field set:


<apex:inputField value="{!selectedWrapper.kavObj[]}">




The Publish status shows up as a drop down with 'Published, Archive, and Draft' values. I can then select a Published value, which is accepted. Then I simply perform a DML upsert on the KAV object (it's stored as an SOBject in the Apex).


Here are some screenshots demonstrating the fallout from doing this. Articles created this way are semi-published, show up in SOSL or search results as published, but can no longer be modified from the SFDC interface:




Thanks for pointing it. You should not be able to create an article with Published status. I open a bug to fix this behavior. 




Good to hear. Too bad we're not getting Publish functionality via the API yet though....I was uber excited when I thought for a split second it was there already.