1

In Salesforce Knowledge, we maintain a formula field that gives the URL of the article. This formula detects the PublishStatus and only gives the URL when the article is published.

i.e., mycompany.force.com/ViewArticle?id=kaAxxxxxxxxxxxxxxx

However, we have recently discovered that users are updating published Articles without creating a new version by unchecking the "Flag as a New Version" checkbox in the "Publish Article" box.

The "Flag as a new Version" box is unchecked by the user.

Doing this, we have learned, updates the ID of the KnowledgeArticleVersion and removes all trace of the prior published version ID.

For Example:

  1. User creates an Article and publishes it. Salesforce creates a KnowledgeArticleVersion record with Version 1, say kaA000000000001.
  2. Later, the User comes back and clicks Edit on the article, and makes some edits.
  3. The user now clicks Publish, unchecks the "Flag as a New Version" and clicks OK.
  4. Salesforce creates a new KnowledgeArticleVersion that is still Version 1, but carries a new ID, say kaA000000000002.

In this case, there is no trace of kaA000000000001. Querying for it gives no rows:

select knowledgearticleid from knowledgearticleversion where id = 'kaA000000000001' and publishstatus = 'archived'

This gives no results for any of the valid PublishStatus values of archived, online, or draft.

On our Community, we have a process in the VF page that translates old ID's coming in via URL parameter to current published ID's, in case there are old blog posts, case comments, etc. floating out there.

So I need to trap that old ID somehow, but I understand that I can't create triggers on Knowledge objects.

Does anyone have any best practices for this? Thank you in advance.

2
  • Each time new version is published, a new Id of KnowledgeArticleVersion is created...so it's not safe to use this....instead that use KnowledgeArticleId field it would always redirect user to correct version.. something like this: mycompany.force.com/ViewArticle?id=kA1D00000001PQ6KAM
    – Ayub
    Commented May 7, 2018 at 17:30
  • I'm aware and have custom code on the Community that does a translation. So any KnowledgeArticleVersion passed in via parameter will be translated to the newest version. However, I can't determine the right way to trap the ID when the published Article is updated without a new Version. Commented May 7, 2018 at 21:46

1 Answer 1

0

Well, when you say that you

process in the VF page that translates old ID's coming in via URL parameter to current published ID's, in case there are old blog posts, case comments, etc. floating out there.

I think that this is wrong, and instead you could leverage URL Title field which is used for public article link.

By the way, I don't recommend to use Knowledge__ka Id even if it is available as a lookup on Knowledge__kav, since those Id would change as you migrate from one environment to another one

If translation of OLD Id is hard business requirement, I would create a field on Knowledge__kav to store it, but since Knowledge__kav do not support neither External Id nor Unique fields, this is not very effective.

So I need to trap that old ID somehow, but I understand that I can't create triggers on Knowledge objects.

You can have triggers on Knowledge__kav but not on Knowledge__ka.

Does anyone have any best practices for this?

Yes, use URL Title. If you migrate articles from the legacy system, store legacy Id into URL title. Then even if Knowledge__kav Id is changed, URL Title will remain the same.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .