I tried this a few years ago in another life, but we ended up being able to skip the issue by using solutions. I can’t avoid it this time, so I’m hoping someone can help me.
I’m trying to give users a button to attach knowledge articles to a case. I’ve been able to return the list of knowledge articles by loading a model for the specific article type (Support Procedure) and setting a condition of PublishStatus = ‘Online’. This allows me to show the Support Procedures in a table without an issue.
However, in order to attach an article I need to be able to create a new record in CaseArticle where the Case ID and the Knowledge Article Version ID are set.
This is where things get dicey. If I look at this guide for knowledge development (https://resources.docs.salesforce.com/sfdc/pdf/salesforce_knowledge_dev_guide.pdf) specifically on page 13, I see that it breaks down to basically
Case -> CaseArticle -> Knowledge Article (Support_Procedure_ka) -> Knowledge Article Version (Support Procedure_kav).
If I try to take the simple route and create a new CaseArticle, I can’t see KnowledgeArticle VersionIds, however if I set the KnowledgeArticleVersionId to a template field and put it as this: {{{KnowledgeArticleVersionId}}} it shows up just fine for existing CaseArticles. Here’s an example showing both the Knowledge Article and Knowledge Article Version.
Once I try to create a new one and search for a Knowledge Article (not version, which doesn’t allow me to search) however it returns no results and gives me some fun errors:
So to my question: Does anyone have any experience with Knowledge Articles and attaching them? I feel like I’m either running into a bug at this point, but I’m not sure how to work around it.
Here’s my XML if needed (you would need to change the sobject to your own article type):
Published Date
Template Field
{{{KnowledgeArticleVersionId}}}
Another Template Field
{{{KnowledgeArticleId}}}