+ Start a Discussion
Diego OlveraDiego Olvera 

How to add a compact layout into a layout through metadata?

Hi, good morning. 
I created a compact layout but I want to add it into a layout.
I edited the standard object "Opportunity" adding:
<compactLayouts>
<fullName>....</fullName>
<fields>...</fields>
</compactLayouts>
tags to add fields I made but I don't know where to add these elements in a page layout because some elements are distributed in differents tags like:
 
<layoutColumns>
            <layoutItems>
                <behavior>Edit</behavior>
                <field>.......</field>
            </layoutItems>
</layoutColumns>

Thanks for your time,
Regards. 
 
Nubes Elite Technologies Pvt. LtdNubes Elite Technologies Pvt. Ltd
Hi Dlego,
You can try this.

Compact layout can be retrieved using objectname . compact layout name api as shown below. here oppcompact is compact layout name.
<types>
    <members>Opportunity.oppcompact</members>
    <name>CompactLayout</name>
  </types>
you can use https://packagebuilder.herokuapp.com/ to build your package.xml

Compact layouts are defined as part of the custom object, standard object, or external object definition.

You need to have it defined in the Object's metadata xml definition as below:
<compactLayouts>
    <fullName>testCompactLayout</fullName>
    <compactLayoutItems>textfield__c</compactLayoutItems>
    <label>testCompactLayoutLabel</label>
</compactLayouts>


Thank You,
www.nubeselite.com
Development | Training | Consulting

Please mark this as solution if your problem is solved.

 
Rahul Kukreja 5Rahul Kukreja 5
Hey, did you get the solution?
I am having similar kinda problem.
Compact Layout in the target org is deployed but the assignment for the compact layout still shows as System.
I have defined the assignment in the tags <compactLayoutAssignment>compactLayoutName</compactLayoutAssignment> 
can you help me with this?