Loading

Create a Lightning Knowledge Article URL that doesn't change

Julkaisupäivä: Oct 13, 2022
Kuvaus
In Lightning, knowledge article URLs aren't static and can change if an article has been set to draft and re-published. Users may report the following error upon attempting to navigate to a knowledge article directly via it's direct URL:
 
Looks like there's a problem.

Unfortunately, there was a problem. Please try again. If the problem continues, get in touch with your administrator with the error ID shown here and any other related details. We couldn't find the record you're trying to access. It may have been deleted by another user, or there may have been a system error. Ask your administrator for help.

In Lightning Knowledge, URLs for articles contain the Knowledge Article Version Id. This means that each time an article's status changes, i.e. it's set to draft and re-published in Lightning, the Id contained in the URL for the article will change. This happens regardless of whether 'Flag as new version' is selected when publishing.

This behavior is not present when accessing a knowledge article via direct URL in Salesforce Classic. This is because the URL to a knowledge article in Classic includes the article's Knowledge Article Id. Unlike KnowledgeArticleVersion, the Id of a KnowledgeArticle record remains constant irrespective of version changes. Reference: KnowledgeArticle | SOAP API Developer Guide

The record Id contained in the URL in Lightning begins with 'ka' which indicative of a KnowledgeArticleVersion Id where as in Classic, the Id in the URL will begin with 'kA' which is indicative of a KnowledgeArticle Id. For more details on the differences between these objects see Salesforce Knowledge SOAP API.

This difference in application behavior between Classic and Lightning was a conscientious design decision that's dependent on how articles are returned in Lighting Experience and is working as expected.

If you would like to see this functionality changed with a future release please consider either creating or promoting an existing Idea on the IdeaExchange so that we may see static knowledge article URL's added to Lightning Experience with a future release.
 
Ratkaisu
As a workaround, you may consider creating a custom text formula field and adding it to Knowledge Article page layouts to provide users with the ability to copy/paste a static link to articles. This can be created using the standard Article URLName field to construct a static Lightning URL.

The exact syntax of the static article URL we'll be constructing is available in the Create Persistent Links to Lightning Knowledge Articles documentation.


Example persistent Lightning Knowledge Article URL with explanation of its URL parameters:


https://{domain.lightning.salesforce.com}/lightning/articles/{KnowledgeObjectName}/{urlName}?{languageIsoCode}
 
  • {domain.lightning.salesforce.com} - This is the first part of your org's unique Lightning URL. For example, if a URL to an article in your org is:

https://jflightning-dev-ed.lightning.force.com/lightning/r/Knowledge__kav/ka00H0000015BOxQAM/view

Then you would replace {domain.lightning.salesforce.com} with: jflightning-dev-ed.lightning.force.com
 
  • ​​{KnowledgeObjectName} - This is the 'Object Name' field value from your Knowledge object's setup page. This can be found in Lightning by navigating to Setup, open Object Manager | locate your Knowledge object and choose the Edit action in the drop down picker on the right hand side of the entry for your Knowledge object in the list. From Salesforce Classic navigate to setup, enter Knowledge in the Quick Find box, then select Knowledge Object Setup.
 
  • {urlName} - This is the value contained in the standard article field, 'URL Name' and can be dynamically populated into the formula example (below) by selecting the field.
 
  • {languageIsoCode} - For a single language Knowledge base you do not need to include this and it can be removed and ignored from the URL syntax entirely.
 

Build a Formula Field with 'Formula Return Type:' Text to create a clickable hyperlink for users to right click copy/paste the static article URL.


Note: Replace KnowledgeObjectName in the formula examples below with your org's unique 'Object Name' field's value from your Knowledge object setup as outlined in the {KnowledgeObjectName} URL variable's details above.

For orgs with a single language knowledge base:


"&HYPERLINK("/lightning/articles/Knowledge/"&UrlName,"Right click and copy link to share this Article's URL")


For organizations that have a multiple language knowledge base:
 
 
"&HYPERLINK("/lightning/articles/Knowledge/"&UrlName&"?language="&TEXT(Language),"Right click and copy link to share this Article's URL"))
Knowledge-artikkelin numero

000384278

 
Ladataan
Salesforce Help | Article