I am trying to publish an article from a flow. I have already created the article successfully(in the flow), but the item is created in "Draft" status. Once the article is created, I am capturing the newly-created record id. I would like to take that id, and use the "publishArticle(articleId, flagAsNew)" syntax found here to publish that article.

I don't seem to be able to do this declaratively so I thought if I could use the @invocablemethod on apex code, I could just pass the article id in a flow to the apex piece, and voila! - newly published article.

I am not a developer by trade. I have tried to write this apex and failed miserably. I will spare you my horrible snippets, as it would likely make your brain hurt!

Any help would be greatly appreciated! :-)

2 Answers 2


For anyone interested, I abandoned the decision to try and write code for this. After giving it some thought, the best course of action is to create knowledge actions. I don't know why I didn't think of this sooner. I suppose it's because you cant do this in a flow - you have to initiate a knowledge action in workflow. Somehow I was only thinking of alternatives that related to flow, hence the rabbit hole of trying to write apex!

I ended up using flow to create the article with some very specific criteria provided by the user. If "Publish Immediately" is checked the new article will go public right away. If it is left at the default value of "false" then the article gets created in draft form which allows for review, etc. The workflow that calls the knowledge action specifically looks for a new record with an article type and that "Publish Immediately" to be checked.

  • Thanks for the inputs, I did a quick POC on this and it worked. I will update if I see any challenge with this approach. In our scenario, we wanted to use it for data loader operations. Aug 5, 2020 at 11:45

Hope this helps. Take in mind the parameter in @InvocableMethod should be a List. More details in this thread

public class DummyClass {
public static void publishArticle(List<ID> articleId){
    KbManagement.PublishingService.publishArticle(articleId.get(0), true);


  • Thank you so much for answering this. I created the class and connected it to my flow. It did not publish the article but left it in draft form. Any thoughts? Jul 14, 2018 at 16:55
  • Also, I just had a thought. The output of my "Record Create" action is the single stored variable from the flow - varCreatedArticleID. I think it is a single string, not a collection or SOBJCollection variable. Will that cause the Apex connector not to fire correctly? I could try to pass a collection to Apex instead. Strange thing is that I didnt get any errors. Jul 14, 2018 at 16:58
  • Hi @matias, How do we send KnowledgeArticleId from process builder , I dont see that field in the process builder field reference,
    – Quddus
    Jan 25, 2019 at 9:47
  • Hi @Quddus. Check the permissions for the field. Also there's an example similar here: salesforce.stackexchange.com/questions/224277/… Jan 26, 2019 at 11:11
  • 1
    Hi,Yes I got it the another day , there is no direct field available in process builder with knowledge article Id which the publish method needs. I have to send the Knowledge Id and then query the knowledge article Id and finally used that Id in the publish article
    – Quddus
    Jan 28, 2019 at 8:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.