+ Start a Discussion
Val Grasparil 4Val Grasparil 4 

Package.xml layouts issue

I am using metadata to deploy changes to my various environments. Since I have multiple BAs working in the same sandbox, they sometimes make field changes that do not need to be promoted to the other environments. In our package.xml, we are specifying every field in the CustomField section as opposed to doing a select all in the CustomObject. This provides a lot more granular control when we are merging to the different brances in our source control.

What I am noticing is that when i refresh my .object file, it is only grabbing the fields that are specified in my package.xml which I would expect. However, I notice that layouts seems to grab everything, including fields not specified in the package.xml. As you can imagine this causes issues because it now throws errors saying the CustomField does not exist.

Is this a defect in the metadata api? Or is there a workaround? Ideally i would not like to include some of these fields that potentially are POCs and not needed in Prod.
I don't think it's a defect. I think because you're retreiving the page layout with the POC fields included, it's looking for those fields when you deploy it. As a work around, remove the fields from the Page Layout then try it again. It's not the best solution but it'll get you going.  
Rakesh BoddepalliRakesh Boddepalli
Salesforce objects metadata is a composite metadata, it has listviews, recordtypes, fields, loookup filters , custom fields . So salesforce retrieves only selected object metadata based on your pacakge.xml. Menaing if you have included only certain custom fields then only they are retrieved.
Whereas layouts are treated separetly they have their own metdata definition so salesforce retrieve the full layout configuration of what you have in your org. But when you port this layout to other org, if the fields are not present in the destination org you will encounter errors.

So as Ray mentioned if you need only the specific layout section then you need to modify the layout and retrieve it or else if you are comfortable with xml you can modify the generated layout xml file to remove the unwanted field tags and port it.

Val Grasparil 4Val Grasparil 4
Thanks. I did consider this an option. My package.xml does explicitly call out each CustomField as opposed to a wildcard on a CustomObject. This gives us finer control of what we are pulling from SFDC when getting the metadata and makes merging to our main branch much easier. Since we have multiple devs playing around in our Sandbox, removing these fields from the .layout will not scale with having multiple devs playing around. I guess we'll have to make the decision on either:
1. Remove the fields from the layout
2. Include these fields which may not be used in Prod in our package.xml so it does not throw errors
3. Add another lower level sandbox which our devs could merge into a feature branch