You need to sign in to do that
Don't have an account?

Dispalying all objects in organization with its keyprefixs ?
Hai friends,
i want to display all objects with its keyprefix values for this i done like this
in controller class:
public class GettingObjectsAndKeyPrifix {
public List<Schema.SObjectType> gd {get;set;}
public List<String> objectMap {get;set;}
Public GettingObjectsAndKeyPrifix(){
gd= Schema.getGlobalDescribe().Values();
objectMap = new List<String>();
for(Schema.SObjectType f : gd)
{
objectMap.add(f.getDescribe().getKeyPrefix());
}
System.debug('--------- --'+gd);
System.debug('+++++++++ --'+objectMap.size() );
}
}
in visual force page:
<apex:page controller="GettingObjectsAndKeyPrifix">
<!--http://srinivas4sfdc.blogspot.in/2013/12/list-of-salesforce-object-key-prefixes.html-->
<apex:pageBlock >
<apex:pageBlockSection >
<apex:pageBlockTable value="{!objectMap}" var="o">
<apex:column value="{!o}"></apex:column>
</apex:pageBlockTable>
<apex:pageBlockTable value="{!gd}" var="g">
<apex:column value="{!g}"></apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>
here output is comming ,but i want output like
account--001
Note-002
like this how can i please help.
i want ouput like this in url
http://srinivas4sfdc.blogspot.in/2013/12/list-of-salesforce-object-key-prefixes.html
i want to display all objects with its keyprefix values for this i done like this
in controller class:
public class GettingObjectsAndKeyPrifix {
public List<Schema.SObjectType> gd {get;set;}
public List<String> objectMap {get;set;}
Public GettingObjectsAndKeyPrifix(){
gd= Schema.getGlobalDescribe().Values();
objectMap = new List<String>();
for(Schema.SObjectType f : gd)
{
objectMap.add(f.getDescribe().getKeyPrefix());
}
System.debug('--------- --'+gd);
System.debug('+++++++++ --'+objectMap.size() );
}
}
in visual force page:
<apex:page controller="GettingObjectsAndKeyPrifix">
<!--http://srinivas4sfdc.blogspot.in/2013/12/list-of-salesforce-object-key-prefixes.html-->
<apex:pageBlock >
<apex:pageBlockSection >
<apex:pageBlockTable value="{!objectMap}" var="o">
<apex:column value="{!o}"></apex:column>
</apex:pageBlockTable>
<apex:pageBlockTable value="{!gd}" var="g">
<apex:column value="{!g}"></apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>
here output is comming ,but i want output like
account--001
Note-002
like this how can i please help.
i want ouput like this in url
http://srinivas4sfdc.blogspot.in/2013/12/list-of-salesforce-object-key-prefixes.html
I doubt it might fail because Schema.SObjectType might not be serialisable
#2 Create a wrapper class for capturing required details
Here is some code what you can take forward
Apex
Visualforce
All Answers
it is working fine,but i want output in two columns not in single column
like this in this url
http://srinivas4sfdc.blogspot.in/2013/12/list-of-salesforce-object-key-prefixes.html
I doubt it might fail because Schema.SObjectType might not be serialisable
#2 Create a wrapper class for capturing required details
Here is some code what you can take forward
Apex
Visualforce
it gives an error Error: Compile Error: Illegal assignment from LIST<String> to LIST<GettingObjectsAndKeyPrifix.SObjectInfo> at line 13 column 9
like this i wrote:
public class GettingObjectsAndKeyPrifix{
public List<Schema.SObjectType> gd {get;set;}
public class SObjectInfo {
public string prefix {get;set;}
public string name {get;set;}
}
public List<SObjectInfo> objectMap {get;set;}
public GettingObjectsAndKeyPrifix(){
gd= Schema.getGlobalDescribe().Values();
objectMap = new List<String>();
for(Schema.SObjectType f : gd)
{
SObjectInfo si = new SObjectInfo();
si.prefix = f.getDescribe().getKeyPrefix();
si.name = f.getDescribe().getLabel();
objectMap.add(si);
}
}
}
will you please tell me ,in that format we will get the output or not
it is working thank you so much.
Here are the source code for getting any sObject key prefix.
https://sfdctechsolutions.blogspot.com/2021/07/get-sobject-prefix.html
Please review this.
FROM EntityDefinition
ORDER BY QualifiedApiName ASC
LIMIT 2000 OFFSET 0
Caveats:
• does not support queryMore which means the largest single pull can be 2000 (reason for the LIMIT statement above)
• overcoming the queryMore limitation can be achieved by simply pulling multiple times (reason for the OFFSET statement above)
LIMIT 2000 OFFSET 2000 (means pull 2000 and start at 2000 = would result in records 2000-4000 from your Org)
[my experience is less than 10k records for some well sized Enterprise Orgs which would equate to 5x pulling this query and adjusting the offset]
Alternatively:
filter resultset using a 'where' clause like below, preferrably something that limits resultset to fewer than 2000 records