I'm building a package to eventually put on the app exchange.

I've set up a dev hub, created a developer site with a namespace and configured visual studio code.

I created my components in visual studio and the custom objects in the dev org including the compact layout.

After deploying the components I ran "sf project retrieve start". This pulled down the various changes I'd made in the org as I expected. This included the Objects folder which contains a folder for the custom object with the KP__c.object-meta.xml file and a sub folder for the fields with the .field-meta.xml for each field.

The next step was to deploy the code to a scratch org to make sure everything worked. This is the error I received:

default\objects\KP__c\KP__c.object-meta.xml In field: defaultCompactLayoutAssignment - no CompactLayout named KP__c.KP_Compact_Layout found.

In the KP__c.object-meta.xml file there is a line setting the compactLayout:


but no definition of the layout itself is in there. After some searching I found out how to add the definition to the file.

      <label>KP Compact Layout</label>

I then deployed again to the scratch org and it worked fine and the compact layout was created.

The issue comes when I want to retrieve changes from the org again, the compactLayouts section is removed from my KP__c.object-meta.xml.

Does anyone know why it is not part of the retrieved code or if there is some configuration I am missing that makes it be included?

There are some other posts about setting up compactLayouts but they appear to be structured completely different to the files I've got.

Thanks in advance. Andy

1 Answer 1


Solved my own problem. Posting this in case anyone else experiences something similar.

It turns out my .forceignore file had a line for **layouts which unsurprisingly ignores layouts when uploading and downloading.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .