[SalesForce] Knowledge Article URL from inside Customer Community

Is there a way to send a link to a customer for a Knowledge article that will take them directly to it on the community site? The use case is we send out an email to a customer who has a customer community license and access to knowledge on the customer community. Is there a way to send a URL for a specific article that when they click the URL it will take them to the customer community, where if they aren't logged in already they will have to, then after they log in automatically re-direct them to the article within the customer community?

Best Answer

For most internal pages (behind authentication) within a community, if you attempt to hit the page unauthenticated, you are prompted to authenticate and then redirected to the page your were attempting to access. For some reason however, Knowledge does not work that way. If you attempt to access a Knowledge article that requires authentication and that is not exposed to the Public Knowledge Base, you receive a 404 and not a login prompt. If you wanted to create an IdeaExchange idea around this, I think it's a good one.

Therefore the only way to accomplish this is with your own creative workaround. You'll want to create a Visualforce page that handles the unauthenticated redirect, call it KnowledgeRedirect or something. This page will need to be exposed via the communities Sites settings to unauthenticated users (via Public Access Settings for the VF page). The page would accept a querystring parameter that is either the id or name of your knowledge article (some unique identifier). On hitting the page with that querystring param, you would first check to see if the user is authenticated. This should suffice in apex:

if (UserInfo.getUserType()=='Guest') { 
    //redirect to the login page with the querystring param on the startUrl or retUrl, I can't recall, one of those
} else {
    //redirect to the knowledge article
}
Related Topic