Retrieves metadata about page layouts for the specified object type.
DescribeLayoutResult = sfdc.describeLayout(string sObjectType, ID recordTypeID[]);
Use this call to retrieve information about the layout (presentation of data to users) for a given object type. This call returns metadata about a given page layout, such as the detail page layout, the edit page layout, and the record type mappings. For additional information about page layouts, see "Customizing Page Layouts" in the Salesforce online help.
Generally, user profiles have one layout associated with each object. In Enterprise and Unlimited Editions, user profiles can have multiple layouts per object, where each layout is specific to a given record type. This call returns metadata for multiple layouts, if applicable.
If you supply a null value for recordTypeId, all the layouts for that user are returned, instead of just the layouts for each specified record type. The same layout may be associated with multiple record types for the user’s profile, in which case there would only be one layout returned.
Use the following procedure to describe layouts:
For more information about person account record types, see Person Account Record Types.
private void describeLayoutSample(){
try {
String objectToDescribe = getUserInput("Enter an object name: ");
DescribeLayoutResult dlr = binding.describeLayout(objectToDescribe);
System.out.println("There are " + dlr.getLayouts().length +
" layouts for the " + objectToDescribe + " object.");
for (int i=0;i<dlr.getLayouts().length;i++){
DescribeLayout layout = dlr.getLayouts(i);
System.out.println(" There are " +
layout.getDetailLayoutSections().length + " detail layout sections");
for (int j=0;j<layout.getDetailLayoutSections().length;j++){
DescribeLayoutSection dls = layout.getDetailLayoutSections(j);
System.out.println(new Integer(j).toString() +
" This section has a heading of " + dls.getHeading());
if (layout.getEditLayoutSections() != null) {
System.out.println("There are " +
layout.getEditLayoutSections().length + " edit layout sections");
}
for (int k=0;k<layout.getEditLayoutSections().length;k++){
DescribeLayoutSection els = layout.getEditLayoutSections(k);
System.out.println(new Integer(k).toString() +
" This section has a heading of " + els.getHeading());
System.out.println("This section has " +
els.getLayoutRows().length + " layout rows.");
for (int l=0;l<els.getLayoutRows().length;l++){
DescribeLayoutRow lr = els.getLayoutRows(l);
System.out.println(" This row has " + lr.getNumItems() + " items.");
for (int h=0;h<lr.getLayoutItems().length;h++){
DescribeLayoutItem li = lr.getLayoutItems(h);
if (li.getLayoutComponents() != null) {
System.out.println(" " +
new Integer(h).toString() +
" " + li.getLayoutComponents(0).getValue());
}
}
}
}
}
}
if (dlr.getRecordTypeMappings() != null)
System.out.println("There are " +
dlr.getRecordTypeMappings().length + " record type mappings for the " +
objectToDescribe + " object");
else
System.out.println("There are no record type mappings for the " +
objectToDescribe + " object.");
} catch (Exception e) {
System.out.println("An exceptions was caught: " + e.getMessage());
getUserInput("Press enter to continue...");
}
}
private void describeLayoutSample()
{
try
{
Console.Write("Enter the name of an object to describe the layout of: ");
string objectToDescribe = Console.ReadLine();
sforce.DescribeLayoutResult dlr = binding.describeLayout(objectToDescribe);
Console.WriteLine("There are " + dlr.layouts.Length + " layouts for the " +
objectToDescribe + " object.");
for (int i=0;i<dlr.layouts.Length;i++)
{
sforce.DescribeLayout layout = dlr.layouts[i];
Console.WriteLine(" There are " + layout.detailLayoutSections.Length +
" detail layout sections");
for (int j=0;j<layout.detailLayoutSections.Length;j++)
{
sforce.DescribeLayoutSection dls = layout.detailLayoutSections[j];
Console.WriteLine(j + " This section has a heading of " +
dls.heading);
}
if (layout.editLayoutSections != null)
{
Console.WriteLine(" There are " + layout.editLayoutSections.Length
+ " edit layout sections");
for (int j=0;j<layout.editLayoutSections.Length;j++)
{
sforce.DescribeLayoutSection els = layout.editLayoutSections[j];
Console.WriteLine(j + " This section has a heading of " +
els.heading);
Console.WriteLine("This section has " + els.layoutRows.Length +
" layout rows.");
for (int k=0;k<els.layoutRows.Length;k++)
{
sforce.DescribeLayoutRow lr = els.layoutRows[k];
Console.WriteLine(" This row has " + lr.numItems +
" items.");
for (int h=0;h<lr.layoutItems.Length;h++)
{
sforce.DescribeLayoutItem li = lr.layoutItems[h];
if (li.layoutComponents != null)
Console.WriteLine(" " + h + " " +
li.layoutComponents[0].value);
}
}
}
}
}
if (dlr.recordTypeMappings != null)
Console.WriteLine("There are " + dlr.recordTypeMappings.Length +
" record type mappings for the " + objectToDescribe + " object");
else
Console.WriteLine("There are no record type mappings for the " +
objectToDescribe + " object.");
}
catch (Exception e)
{
Console.WriteLine("An exceptions was caught: " + e.Message);
}
}
| Name | Type | Description |
|---|---|---|
| sObjectType | string | The specified value must be a valid object for your organization. For a complete list of objects, see Standard Objects. If the object is a person account, specify Account, or if it is a person contact, specify Contact. |
| recordTypeId | ID[] |
Optional parameter restricts the layout data returned to the specified record types. To retrieve the layout for the master record type, specify the value 012000000000000AAA for the recordTypeId regardless of the object. This value is returned in the recordTypeInfos for the master record type in the DescribeSObjectResult. Note that a SOQL query returns a null value, not 012000000000000AAA. For information on IDs, see ID Field Type. |