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
subbu123.pbt@gmail.comsubbu123.pbt@gmail.com 

SOSL Query

how to get the list of all avilable sobjects in salesforce database ?  using soql,sosl,apex  any one .

subbu123.pbt@gmail.comsubbu123.pbt@gmail.com
i want to know the count of sobject in salesforce organization. and number of fields in single object . this is my requirement.
Sfd developerSfd developer

Hi,

 

try this,

 

Apex Class:

public class clsObjects{
	public Map<String, Integer> 		mapObjandFields 		{get;set;}
	
	public List<String> getOrgObj(){
		List<String> orgObjects = new List<String>();
		for (Schema.sObjectType obj : Schema.getGlobalDescribe().keySet()){
			if (!mapObjandFields.containsKey(obj.getDescribe().getLabel())){
				mapObjandFields.put(obj.getDescribe().getLabel(), Schema.getGlobalDescribe().get(obj).getDescribe().fields.getMap().zize());
				orgObjects.add(obj.getDescribe().getLabel());
			}
		}
		orgObjects.sort();
		return orgObjects;
	}
}

 

Page:

 

<apex:page controller="clsObjects" >
	<apex:form>
		<apex:pageBlock >
			<apex:pageBlockTable value="{!OrgObj}" var="obj">
				<apex:column value="{!obj}" />
				<apex:column value="{!mapObjandFields[obj]}" />
			</apex:pageBlockTable>
		</apex:pageBlock>
	</apex:form>
</apex:page>