You need to sign in to do that
Don't have an account?
Rakesh Kumar
How can i get all Object's field(custom and standard) in single click ??
Hi techie,
I am looking for apex code which can get all objects field in single click .
I can get all custom fields according to particular objects but i cant able to get all custom and standard fields in single click.
Is there any way to get all fields in single select or click?
Thanks in advance.
Rakesh
You can make a Describe call to retrieve the metadata.
I suggest that you create a visualforce page with a dynamic piclist of sobjects, and a custom button with an apex method that returns all the available field names for that object.
http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_describesobject.htm
Hi Chris,
Thanks for reply.
I can get list of all objects and according to selected object i can get all fields but my requirement is not get specific Object's Field i would like to get all object's field in single array.
I hope it will make sense about my requirement.
Thanks
Rakesh
Hi Rakesh,
This is normally how you would retrieve the sObject Fields:
// Get the list fo Fields for the selected object
public void getObjectFields(){
childObjectFields = new List<SelectOption>();
Map<String, Schema.SObjectField> mapFields = Schema.getGlobalDescribe().get(YOURSOBJECTNAME).getDescribe().fields.getMap();
List<String> sortedKeyset = new List<String>();
for (String fieldName: mapFields.keyset()){
sortedKeyset.add(fieldName);
}
sortedKeyset.sort();
for (String fieldName: sortedKeyset){
childObjectFields.add(new SelectOption(fieldName, fieldName));
}
return;
}
You may have to loop through all the sobjects and add they are fields to the map.