describeLayout
Syntax
DescribeLayoutResult = sfdc.describeLayout(string sObjectType);Usage
Use describeLayout to retrieve information about the layout (presentation of data to users) for a given object type. The describeLayout call returns metadata about a given page layout, including layouts for edit and display-only views and record type mappings. Note that field-level security and layout editability affects which fields appear in a layout.
Users typically have one layout per object type assigned in their user profiles. In the Enterprise Edition, users can have multiple layouts, associated with multiple record types, defined in their user profile. The describeLayout call returns metadata for multiple layouts, if applicable.
:: Note:
The describeLayout call is an advanced API call that is typically used only by partners who have written custom page rendering code for generating output on a specialized device (for example, on PDAs) and need to examine the layout details of an object before rendering the page output.
Basic Steps for Describing Layouts
Describing layouts involves the following basic steps:
- To display a detail page, a client application first gets the recordTypeId from the record, then it finds the layoutId associated with that recordTypeId (through recordTypeMapping), and finally it uses that layout information to render the page.
- To display an edit page, a client application first determines whether more than one record type is available and, if so, presents the user with a choice. Once a record type has been chosen, then the client application uses the layout information to render the page. It uses the picklist values from the RecordTypeMapping to display valid picklist values for picklist fields.
- A client application uses describeSObject to get the labels for layout, using the value field on DescribeLayoutComponent to perform a lookup on the DescribeSObjectResult when the LayoutComponent is of type
field.Sample Code-Java
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 j=0;j<layout.getEditLayoutSections().length;j++){ DescribeLayoutSection els = layout.getEditLayoutSections(j); System.out.println(new Integer(j).toString() + " This section has a heading of " + els.getHeading()); System.out.println("This section has " + els.getLayoutRows().length + " layout rows."); for (int k=0;k<els.getLayoutRows().length;k++){ DescribeLayoutRow lr = els.getLayoutRows(k); 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()); } }Sample Code-C#
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); } }Arguments
Name Type Description sObjectType string The specified value must be a valid object for your organization. For a complete list of sforce objects, see List of sforce Objects.
Response
Fault
See Also
|
© Copyright 2000-2003 SalesForce.com, Inc. |