You need to sign in to do that
Don't have an account?
ForceDev54
Get all the fields from the page layout
Hi,
I have an interesting scenario.
I have a page layout and consider i have 3 fields in the layout.
How do i get all the field api names that are available in a page layout for a custom object in apex?
Thanks in advance
Hi,
DescribeLayout() is a Soap API call, there is a Java example here,
http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_describelayout.htm
Hello ForceDev54
I give you a sample code where you can find how can i get all field of any object dynamically.
I think this is best answer for you. if you find this is good one for you then give me feedback.
public map<string, schema.sObjectType> so = schema.getGlobalDescribe();
schema.sObjectType allSelectedObject = so.get(val);
// Fetching Field Result
schema.DescribesObjectResult result = allSelectedObject.getdescribe();
map<string, schema.sObjectField> f= result.fields.getMap();
for(schema.sObjectField SFields: f.values()){
AllFields.add(new selectoption(SFields.getDescribe().getName(), SFields.getDescribe().getLabel()));
system.debug('----------SFields.getDescribe().getLabel()----------'+SFields.getDescribe().getLabel());
}
if you find any dificulty with this you can contact me again.
Thanks.
https://salesforce.stackexchange.com/questions/240726/is-there-a-way-to-query-exclusively-the-fields-in-the-page-layout-for-an-sobject