9

It's a bit inconvenient that this returns null:

system.debug( Schema.getGlobalDescribe().get('KnowledgeArticleVersion') );

While this does not:

system.debug( KnowledgeArticleVersion.getSObjectType().getDescribe() );
4
  • 2
    Does your current user have a license to knowledge? Since it's a standard object I believe the latter type will always be able to reference it while apex run with sharing won't show inaccessible SObjects in the describe if memory serves. May 11, 2013 at 21:00
  • It's a dev org but the user should have the right license as it can create articles.
    – Jan Julian
    May 12, 2013 at 7:08
  • 1
    Were you able to get this working? I am also facing same issue. Schema.getGlobalDescribe().get('KnowledgeArticleVersion') returns Attempt to de-reference a null object. User does not have any license issue. A SOQL on KnowledgeArticleVersion returns results.
    – Dave
    Jul 11, 2015 at 23:05
  • Hi Dave, please see the answer on this question for help moving forward. Jul 14, 2015 at 21:40

1 Answer 1

5

This will work for you:

DescribeSObjectResult objType = KnowledgeArticleVersion.getSObjectType().getDescribe();
Map<String, SObjectField> fields = objType.fields.getMap();
Set<String> fieldSet = fields.keySet();

for(String s:fieldSet)
{
    SObjectField fieldToken = fields.get(s);
    DescribeFieldResult selectedField = fieldToken.getDescribe();
    System.debug(selectedField.getName());
}

KnowledgeArticleVersion is not available for Schema.getGlobalDescribe().get().

2
  • Getting better at development eh ;)
    – Jan Julian
    Jul 14, 2015 at 22:27
  • Significantly. I actually didn't realize who posted the question until after the fact ;) Jul 15, 2015 at 14:38

You must log in to answer this question.

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