function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SForceBeWithYouSForceBeWithYou 

Schema.getGlobalDescribe() returns more than 1,000

So, I'm dealing with the largest org instance I've ever come across, and apparently when I do a Schema.getGlobalDescribe() and try to put the key set into a Set<String>, I get "Collection size 1,629 exceeds maximum size of 1,000".

Now, I'm no stranger to getting arounds limits... I've obviously ran into data limi problems in this org, and metadata limits on the Eclipse side, but I'm not quite sure how to get around this one, since the Schema.getGlobalDescribe() method is not a SOQL query... It's a method that returns a Map<String,Schema.SObjectType> , and the limit for a map is 1,000. I know with a large query, you can do something akin to this for an org with 30,000 accounts:
for(List<Account> lstAccts : [SELECT Id, Name FROM Account]){
for(Account a : lstAccts){
a.Name = a.Name + ' some change';
}
update lstAccts;
}

... but the method Scena.getGlobalDescribe() is not a query, it's a method call that returns a Map<String,Schema.SObjectType>. How can I populate a full set (or list of sets) of API names of SObjects in my org if there's more than 1,000?

Here's what I have so far:

Controller:
public class CustomObjectsViewController{
public Map<String,Schema.SObjectType> mapGDescribe{get; set;}
public Set<String> setObjNames{get; set;}

public CustomObjectsViewController(){
this.mapGDescribe = Schema.getGlobalDescribe();
this.setObjNames = mapGDescribe.keySet();
}
}

VisualForce Page:
<apex:page controller="CustomObjectsViewController">
<apex:pageBlock >
<apex:pageBlockTable value="{!setObjNames}" var="objName">
<apex:column value="{!objName}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>

Error when loading VFpage:
Collection size 1,629 exceeds maximum size of 1,000

Note:
At the end of the day... I'm really trying to implement a List View of custom objects.
All I want is a list view "Unmanaged Custom Objects" like I have for classes, triggers, components, and VFpages.
Is there an idea like that I can vote for?

Any help is GREATLY appreciated.


Thanks,

Nathan Pepper
SalesForce.com Developer
YouTube: www.youtube.com/MayTheSForceBWithYou
Twitter: @SForceBeWithYou
kibitzerkibitzer

There are two possibilities. One is that this is older code? The 1000 item limit in collections was lifted in summer '10 (which I think was API version 19).

 

If it's newer code, the issue is probably that the limit still exists for collections used as sources on VisualForce elements (repeat, datatable, etc.), but this shouldn't apply to getGlobalDescribe.  I don't have an org that large myself, so can't verify it.

 

In this example, you're trying to use the collection as a source to a datatable - that will fail.

 

What you'll need to do is capture the data into a collection (which itself is not subject to the limit). Then split the data into two separate collections to use as parameters to two separate data tables.

 

Or, if appropriate for your application, filter out the objects that you actually want to display from the collection you're using in the datatable (filter out standard objects, objects belonging to selected apps, etc.).

 

Dan

 

Sumit@TCSSumit@TCS
<apex:page standardStylesheets="false" controller="InvoiceReportAttachment" sidebar="false" readOnly="True">