I am trying to query list of fields for certain objects, have the following query which works fine for standard and custom objects but now for managed package objects.

SELECT QualifiedApiName, DeveloperName, Description, DataType, LastModifiedById, LastModifiedDate 
FROM FieldDefinition 
WHERE EntityDefinition.DeveloperName='Account'

but this doesn't work for the managed package object,what would be an alternative that works?

1 Answer 1


The managed package object fields are not accessible via a SOQL query. Alternative to this you can use the schema class to get the managed package object and its field.

Here is the sample code which returns the specific managed package object fields meta.

Run this in the Developer console Anonymus Window.

Schema.SObjectType targetType = Schema.getGlobalDescribe().get('biztechcs__Customer_Portal_Role__c');
Map<String, Schema.SObjectField> fieldMap = targetType.getDescribe().fields.getMap();
for (Schema.SObjectField field : fieldMap.values()) {
    Schema.DescribeFieldResult dfr = field.getDescribe();
    System.debug('Field Name--> '+ dfr.getName());
    System.debug('Field Label--> '+ dfr.getLabel());

Reference document for the DescribeFieldResult Class: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_fields_describe.htm#apex_Schema_DescribeFieldResult_getLabel

You must log in to answer this question.

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