How To Find Fields That Are Part Of Page Layout In Salesforce?

How To Find Fields That Are Part Of Page Layout In Salesforce?
In this blog, you will learn how you can find the fields that are part of page layout in salesforce.

Follow below simple steps

  • Go to Setup
  • Open Developer Console
  • Go To Debug menu
  • Select Open Execute Anonymous Window from dropdown


List<Metadata.Metadata> layouts = Metadata.Operations.retrieve(
    Metadata.MetadataType.Layout, new List<String>{'Account-Account Layout'}
);

Metadata.Layout layout = (Metadata.Layout)layouts.get(0);

for(Metadata.LayoutSection layoutSection : layout.layoutSections){
for(Metadata.LayoutColumn layoutColumn : layoutSection.layoutColumns){
if(layoutColumn.layoutItems != null){
for(Metadata.LayoutItem layoutItem : layoutColumn.layoutItems){
if (layoutItem.field != null){
System.debug(layoutItem.field);
}
}
}
}
}

  • Click on Execute


Follow Us

Posted By : Sudeer Kamat Date :

view_module Related

label Labels

Comments 0