I am querying the KnowledgeArticleVersion table to list all articles in order to display a list of links to articles.

Because of some limitations I cannot use the <knowledge:articleList> tag.

I have these article types: Documentation__kav, FAQ__kav, Private_Article__kav.

Other article types will be added later.

How do I find out the article type from the KnowledgeArticleVersion table?

Maybe there are other tables I can query to find this out?

  • I don't have the answer, but the ERD diagram in the Articles online documentation should help. Commented Aug 27, 2012 at 19:30
  • It should, but it doesn't :) Commented Aug 28, 2012 at 12:02

3 Answers 3


I found how to do it.

As @scyforce said I need to use the key prefix.

Link on Salesforce Community

Code from that page:

    // Create DescribeMap
    private void createDescribeMap() {
        Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe();
        Set<String> keySet = gd.keySet();
        for (String key : keySet) {
            Schema.SObjectType objectType = gd.get(key);
            if (key.endsWith('ka') || key.endsWith('kb')) {
                this.describeMap.put(objectType.getDescribe().getKeyPrefix(), objectType.getDescribe().getLabel());

    //Util method to get Article Type from article Id.
    public String getArticleType(String articleId) {
        String articlePrefix = articleId.substring(0,3);
        Set<String> keySet = describeMap.keySet();
        String articleType = null;
        for(String key: keySet) {
            if(articlePrefix.equalsIgnoreCase(key)) {
                articleType = describeMap.get(key);
                return articleType;
        return articleType;
  • One suggestion, when putting the values in the describeMap, convert the keyPrefix to lower case. Then you don't need the for loop and equalsIgnoreCase in getArticleType. Commented Aug 28, 2012 at 19:48
  • 1
    Also, is there something special about key prefixes that end in 'ka' or 'kb'? I'm not sure that it is correct. E.g. the key prefix from 'ka4S0000000CaTSIA0' wouldn't match. I suspect it should be checking that the objecttype ends with '__kav'. Commented Aug 28, 2012 at 19:53

5 years later and this data is now exposed on the KnowledgeArticleVersion table itself.

Type: string
Properties: Defaulted on create,Filter
Description: Indicates the API Name of the article type.  
    The ArticleType is assigned to the article when it's created. 
    You can't change the value of this field.  
    This field is available in API version 26.0 and later.

U need to have a key prefix mapping table in order to find the article type. Thanks.

  • So does the key prefix on the KnowledgeArticleVersion.Id change based on the article type? Or is it another field? Commented Aug 28, 2012 at 7:24
  • @scyforce: I'm not sure what this means. Could you flesh out this answer a bit more or give an example of how you'd use a "key prefix mapping table"?
    – Benj
    Commented Sep 23, 2012 at 0:28

You must log in to answer this question.

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