Use this call to retrieve information about the compact layout for a given object type. This call returns metadata about a given compact layout, including the record type mappings. For more information about compact layouts, see the Salesforce Help .
Sample Code—Java
This sample shows how to get the compact layouts of an Account sObject. It calls describeCompactLayouts() with the name of the sObject type to describe. After getting the compact layouts, the sample prints the images, fields, and action buttons found for each compact layout. Next, it prints the system default compact layout for the object, then the mapping information of record types to compact layouts.
1public void testDescribeCompactLayoutsSample(){2 try{3 String objectToDescribe = "Account";4 DescribeCompactLayoutsResult compactLayoutResult = connection5 .describeCompactLayouts(objectToDescribe, null);6 System.out.println("There are " + compactLayoutResult.getCompactLayouts().length7 + " compact layouts for the " + objectToDescribe + " object.");89 // Get all the compact layouts for the sObject10 for(int i = 0; i <compactLayoutResult.getCompactLayouts().length; i++){11 DescribeCompactLayout cLayout = compactLayoutResult.getCompactLayouts()[i];12 System.out.println(" There is a compact layout with name: " + cLayout.getName());13 DescribeLayoutItem[]fieldItems = cLayout.getFieldItems();14 System.out.println(" There are " + fieldItems.length + " fields in this compact layout.");1516 // Write field items17 for(int j = 0; j <fieldItems.length; j++){18 System.out.println(j + " This compact layout has a field with name: " + fieldItems[j].getLabel());19}2021 DescribeLayoutItem[]imageItems = cLayout.getImageItems();22 System.out.println(" There are " + imageItems.length + " image fields in this compact layout.");2324 // Write the image items25 for(int j = 0; j <imageItems.length; j++){26 System.out.println(j + " This compact layout has an image field with name: " + imageItems[j].getLabel());27}2829 DescribeLayoutButton[]actions = cLayout.getActions();30 System.out.println(" There are " + actions.length + " buttons in this compact layout.");3132 // Write the action buttons33 for(int j = 0; j <actions.length; j++){34 System.out.println(j + " This compact layout has a button with name: " + actions[j].getLabel());35}3637 System.out.println("This object's default compact layout is: "38 + compactLayoutResult.getDefaultCompactLayoutId());3940 RecordTypeCompactLayoutMapping[]mappings = compactLayoutResult.getRecordTypeCompactLayoutMappings();41 System.out.println("There are " + mappings.length + " record type to compact layout mapping for the "42 + objectToDescribe + " object.");43 for(int j = 0; j <mappings.length; j++){44 System.out.println(j + " Record type " + mappings[j].getRecordTypeId()45 + " is mapped to compact layout " + mappings[j].getCompactLayoutId());46}47}4849}catch(ConnectionException ce){50 ce.printStackTrace();51}5253}
The specified value must be a valid object for your organization. If the object is a person account, specify Account, or if it is a person contact, specify Contact.
recordTypeId
ID[]
Optional parameter that restricts the compact layout data returned to the specified record types.