0

I am building a managed package for our clients which include custom filter and custom sorting of records, I need to consider different cases regarding to field types and display types.

I know that there are several different Display Type values, like DisplayType.Integer and DisplayType.Long, but I don't understand if I can test such values.

Are there any fields which have display types of Integer or Long? Even if I try to create a number field with 0 Decimal Places and with Length of 9 or 18, the resulting DisplayType of such field is still Double, but not Number or Long.

Maybe there is some standard field type that have such DisplayType?

1 Answer 1

1

We need to run two snippets of code to find out any instances of Long and Integer DisplayTypes.

Long:

Set<Schema.DisplayType> displayTypes = new Set<Schema.DisplayType>();

Map<String,SObjectType> stuff = Schema.getGlobalDescribe();

for (SObjectType theType : stuff.values()) {
    Map<String, SObjectField> theFields = theType.getDescribe().fields.getMap();
    
    for (SObjectField theField : theFields.values()) {
        displayTypes.add(theField.getDescribe().getType());
        
        if (theField.getDescribe().getType() == DisplayType.Long) {
            System.debug('Type ' + theType.getDescribe().name + ' has long ' + theField.getDescribe().name);
        }
    }
}

In result we can see that there are two fields which have Long Display Data Type:

Type AppAnalyticsQueryRequest has long DownloadSize
Type PlatformEventUsageMetric has long Value

And Integer:

Set<Schema.DisplayType> displayTypes = new Set<Schema.DisplayType>();

Map<String,SObjectType> stuff = Schema.getGlobalDescribe();

for (SObjectType theType : stuff.values()) {
    Map<String, SObjectField> theFields = theType.getDescribe().fields.getMap();
    
    for (SObjectField theField : theFields.values()) {
        displayTypes.add(theField.getDescribe().getType());
        
        if (theField.getDescribe().getType() == DisplayType.Integer) {
            System.debug('Type ' + theType.getDescribe().name + ' has integer ' + theField.getDescribe().name);
        }
    }
}

In result we can see there are a lot of such fields

Type Asset has integer AssetLevel
Type AssetFeed has integer CommentCount

etc

You must log in to answer this question.

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