public Class Mysobject{
public List<SelectOption> options{get;set;}
public List<SelectOption> Fieldoptions{get;set;}
public Mysobject()
Fieldoptions= new List<SelectOption>();
}
public List<SelectOption> getSobject(){
List<Schema.SObjectType> gd = Schema.getGlobalDescribe().Values();
options = new List<SelectOption>();
Fieldoptions = new List<SelectOption>();
for(Schema.SObjectType f : gd){
options.add(new SelectOption(f.getDescribe().getname(),f.getDescribe().getLabel()));
}
return options;
}
// Here this method is use to get fields of selected Sobject.
private List<SelectOption> GeField(String sobj){
// Sobj is a API Name Of Sobject
Map<String,Schema.SObjectType> fMap= Schema.getGlobalDescribe();
Map<String, Schema.SObjectField> fieldMap = fMap.get(sobj).getDescribe().fields.getMap();
if (fieldMap.size() > 0)
for(Schema.SObjectField sfield : fieldMap.Values()){
Fieldoptions.add(new SelectOption(sfield .getDescribe().getname(),sfield.getDescribe().getLabel()));
}
return Fieldoptions;
}
Apex
,
Metadata API
,
Salesfroce
public List<SelectOption> options{get;set;}
public List<SelectOption> Fieldoptions{get;set;}
public Mysobject()
Fieldoptions= new List<SelectOption>();
}
public List<SelectOption> getSobject(){
List<Schema.SObjectType> gd = Schema.getGlobalDescribe().Values();
options = new List<SelectOption>();
Fieldoptions = new List<SelectOption>();
for(Schema.SObjectType f : gd){
options.add(new SelectOption(f.getDescribe().getname(),f.getDescribe().getLabel()));
}
return options;
}
// Here this method is use to get fields of selected Sobject.
private List<SelectOption> GeField(String sobj){
// Sobj is a API Name Of Sobject
Map<String,Schema.SObjectType> fMap= Schema.getGlobalDescribe();
Map<String, Schema.SObjectField> fieldMap = fMap.get(sobj).getDescribe().fields.getMap();
if (fieldMap.size() > 0)
for(Schema.SObjectField sfield : fieldMap.Values()){
Fieldoptions.add(new SelectOption(sfield .getDescribe().getname(),sfield.getDescribe().getLabel()));
}
return Fieldoptions;
}
No comments:
Post a Comment