You need to sign in to do that
Don't have an account?
ForceRookie
How to get all Standard and Custom Objects only?
How can I get all Objects except the System Objects in SF?
Here's my code. But I need to revise it to get only the needed Objects.
@AuraEnabled public static List<SelectOption> fetchAllObjects(){ Set<String> listObjs = new Set<String>(); for(MyCustomSettings__c cs : [Select Id, Objects__c From MyCustomSettings__c]){ listObjs.add(cs.Objects__c); } List<SelectOption> objList = new List<SelectOption>(); Set<String> csObjNames = new Set<String>(); Map<String, String> mapName = new Map<String, String>(); Map<String, String> mapLabel = new Map<String, String>(); for(Schema.SObjectType objTyp : Schema.getGlobalDescribe().Values()){ System.debug(objTyp.getDescribe().getLabel()); if ( objTyp.getDescribe().isCreateable()) { csObjNames.add(objTyp.getDescribe().getLabel()); mapName.put(objTyp.getDescribe().getLabel(), objTyp.getDescribe().getName()); mapLabel.put(objTyp.getDescribe().getName(), objTyp.getDescribe().getLabel()); } } List<String> objNamesCast = new List<String>(); objNamesCast.addAll(csObjNames); objNamesCast.sort(); for(String s : objNamesCast){ String objTypeName = mapName.get(s); String objTypeLabel = mapLabel.get(objTypeName); if(!listObjs.contains(objTypeName)) objList.add(new SelectOption(objTypeName,objTypeLabel)); else objList.add(new SelectOption(objTypeName,objTypeLabel, true)); } return objList; }
For geting all Standard and Custom Objects use bellow code it may helpful for you.
List<string> SObjectList = new List<string>();
for(Schema.SObjectType objTyp : Schema.getGlobalDescribe().Values()){
String name = objTyp.getDescribe().getName();
if(!name.containsignorecase('history') && !name.containsignorecase('tag')&&
!name.containsignorecase('share') && !name.containsignorecase('feed')){
SobjectList.add(name);
System.debug( 'Name : ' + name);
}
}
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi
All Answers
Sorry for this issue you are facing.
Below is a solution which will give you a list of all standard and custom objects ignoring system objects. Hope this helps.
Kindly mark this as solved if the reply was helpful.
Thanks,
Nagendra
To get the list of all objects in your org, you can use something like this:
Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe();
for(Schema.SObjectType thisObj : gd.values()) {
System.debug(thisObj);
}
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha
For geting all Standard and Custom Objects use bellow code it may helpful for you.
List<string> SObjectList = new List<string>();
for(Schema.SObjectType objTyp : Schema.getGlobalDescribe().Values()){
String name = objTyp.getDescribe().getName();
if(!name.containsignorecase('history') && !name.containsignorecase('tag')&&
!name.containsignorecase('share') && !name.containsignorecase('feed')){
SobjectList.add(name);
System.debug( 'Name : ' + name);
}
}
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi
Thank you everyone!
If you know about integration as well, please help me answer my question here -- https://developer.salesforce.com/forums/?id=9062I000000IK4lQAG