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?
Attribution to: Alexandru Luchian
Possible Suggestion/Solution #1
5 years later and this data is now exposed on the KnowledgeArticleVersion table itself.
https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_knowledgearticleversion.htm
ArticleType
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.
Attribution to: a_sdfc_developer
Possible Suggestion/Solution #2
U need to have a key prefix mapping table in order to find the article type. Thanks.
Attribution to: scyforce
Possible Suggestion/Solution #3
I found how to do it.
As @scyforce said I need to use the key prefix.
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;
}
Attribution to: Alexandru Luchian
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/918