I am working on KnowledgeArticleVersion and want to show the list of articles on Visual force page.
SObjectType objToken = Schema.getGlobalDescribe().get('KnowledgeArticleVersion');
DescribeSObjectResult objDef = objToken.getDescribe();
Map<String, SObjectField> fields = objDef.fields.getMap();
Set<String> fieldSet = fields.keySet();
for(String s:fieldSet)
{
SObjectField fieldToken = fields.get(s);
DescribeFieldResult selectedField = fieldToken.getDescribe();
System.debug(selectedField.getName());
}
When I try to run this through apex, I get an exception
System.NullPointerException: Attempt to de-reference a null object.
I am able to run this SOQL Query using same object,
SELECT Id, Title FROM KnowledgeArticleVersion WHERE
PublishStatus='Online' AND language ='en_US'
The framework that we are using does not allow this SOQL Query to be used and does a describe and fetches fields dynamically.
Can someone please provide a help or pointer on this ?
KnowledgeArticleVersion.getSObjectType()
instead ofSchema.getGlobalDescribe().get('KnowledgeArticleVersion')
.