Update Knowledge Articles in Bulk

Recently we had a big Knowledge Centric Support (KCS) initiative where we generated a ton of Articles for use in a Community. (We're still on Classic Knowledge.)

Problem is, some users forgot to tick the "Customer" box when creating the Articles. So those articles didn't appear to external users in the Community.

You can update these Articles in bulk, but you need to use a few obscure hooks in Apex. This method will create a draft of the Article, update the Knowledge Article Version, and then re-publish without creating a new Version.

The following code will update the 'IsVisibleInCsp' flag for a single Article specified in the 1st query, which will make it visible to Customers.

Here's a bulkified version. This is heavy on the CPU so I run it 10 at a time.

When going over these in bulk, you might run into a situation where there is an existing draft of an article that has been previously published; i.e., it's actively being updated. In this example, we search for those situations and don't create revisions of them.

This will go over all articles of type BA_Public_Knowledgebase__kav, 10 at a time. Update the code for your KnowledgeArticleVersion name, then run in Execute Anonymous. When you're done it will report that it updated 0 articles.


Popular posts from this blog

Custom Lookup For Flows to Avoid "Disjunctions Not Supported"

"Disjunctions not supported" - Why Custom Metadata and Flow Don't Mix