0

I was trying to get fields list and metadata of an article type (ArticleTypeName__kav object), since I can't get if from the Schema.getGlobalDescribe().

That what I was trying:

MetadataService.MetadataPort service = createService();
MetadataService.CustomObject customObject = (MetadataService.CustomObject) service.readMetadata('CustomObject', new String[] { 'MyArticeTest__kav' }).getRecords()[0];
for(MetadataService.CustomField field : customObject.fields)
{
    System.debug('Field Name: ' + field.fullName);
}

But I get null for the customObject.

Note that when I getting all the Custom objects using the following:

List<MetadataService.ListMetadataQuery> queries = new List<MetadataService.ListMetadataQuery>();    
MetadataService.ListMetadataQuery query = new MetadataService.ListMetadataQuery();
query.type_x = 'CustomObject';
queries.add(query);
MetadataService.FileProperties[] fileProperties = service.listMetadata(queries, METADATA_API_VERSION);

I do get my MyArticeTest__kav.

1 Answer 1

1

MetadataService.readMetadata method requires full api name of the object including namespace. Please check your org and see if there is any namespace associated with your custom object, if so, provide full name as namespace__MyArticeTest__kav. Also, when checking the result set use customObject.fullName to compare with null.

You must log in to answer this question.

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