Skip to main content

Resolving validation errors - "Couldn't locate layout section: <xxx> in layout <yyy>"

Resolution to this validation error often associated with CustomObjectTranslation and Layout metadata types

Valerio Chang avatar
Written by Valerio Chang
Updated over a month ago

Explanation of the error

This Salesforce error that Gearset is surfacing is usually encountered when attempting to deploy a CustomObjectTranslation and Layout that belong to a managed package.

This is due to a known bug of the Metadata API that removes the managed package prefix. This then causes an error when the namespace does not match or include the managed package layout tag.

Resolution

To resolve this issue, you will need to add the layout tag back to your deployment or remove the managed package component from your deployment.
​
Gearset will notify you via our problem analysis of any attempted changes that may fail your deployment, like so:
​

However, if you want to deploy the component listed above πŸ‘†, you will need to get more creative.
​
As stated above, you will need to manually edit the XML of your deployment package by following these instructions, like so:
​

Under the <Layouts> tag, on the second line beginning with <layout>, which may look as below (example):

<layouts>
<layout>Example Object Layout</layout>
<sections>
<label><!-- Address Information --></label>
...
</sections>
...
</layouts>

You'd need to amend it to <layout>NameSpace__Example Object Layout>, as shown below:

<layouts>
<layout>NameSpace__Example Object Layout</layout>
<sections>
<label><!-- Address Information --></label>
...
</sections>
...
</layouts>


Note that the word "NameSpace__" referenced in line:

<layout>NameSpace__Example Object Layout</layout>

refers to the name of your managed package that the layout is a part of.

You should not add the exact wording of "NameSpace__" to your XML file, as this will not resolve the error.
​
As per Salesforce documentation on Understanding Namespaces:


"A namespace is a 1-15 character alphanumeric identifier that distinguishes your package and its contents from other packages in your org."
​

Resolution if a failed component is deployed through a CI job

If the failing component is deployed in a CI job, you may need to use our Environment variables feature to apply and maintain those changes when pulling this metadata from your source.

Is the PR failing validation in your Gearset Pipeline?

This workaround can be applied if:

  • The failing Custom object translations don't necessarily need to be promoted as part of your pull request (e.g. you're okay with excluding them from the deployment).

  • Or if Custom object translations that failed the validation are not part of the changes you're working on, but still got included in the CI job's deployment package.

If the main intention is to make sure the PR validates successfully and gets promoted without Custom object translation components affecting it, consider below workaround:

  • Temporarily exclude Custom object translation metadata from your CI job's metadata filter (check our article on managing custom filters in CI jobs for guidance).

  • Once done, re-validate the PR in your Gearset Pipeline.

  • After you've selected "Promote changes" on the PR, wait and allow the CI job to deploy PR's changes to target org.

  • Once the org deployment is done, navigate to CI dashboard, select "Edit settings" for your Ci job, go to "Metadata filters" and include Custom object translation in the filter - this is to make sure that all future CI job runs will include this metadata in their deployments (as per original CI configuration, if applicable).

Other useful resources

Further examples of this Salesforce validation error can be found in:

Disclaimer: This error is returned by Salesforce directly, rather than Gearset. Even so, we offer guidance based on our combined experience with the Metadata API. Where possible, we try to help guide you to fix or avoid this error. In the case that this isn't possible, we may need to direct you to Salesforce support for further clarification.

Did this answer your question?