When deploying a Salesforce Profile metadata file using the Metadata API or Salesforce CLI, the deployment fails with the following error:
"Error parsing file: Element [ElementName] is duplicated at this location in type Profile"
For example: "Error parsing file: Element tabVisibilities is duplicated at this location in type Profile"
This error occurs when the XML structure of the Profile metadata file is modified so that multiple occurrences of the same element type (such as tabVisibilities or userPermissions) are no longer grouped consecutively. In Salesforce Metadata API, all occurrences of the same element type within a complex type (such as a Profile) must be grouped together as a consecutive block in the XML file.
The following XML snippet shows the correct structure — all tabVisibilities elements are grouped together before the userPermissions block:
<tabVisibilities>
<tab>TestObject__c</tab>
<visibility>DefaultOn</visibility>
</tabVisibilities>
<tabVisibilities>
<tab>TestObject2__c</tab>
<visibility>DefaultOn</visibility>
</tabVisibilities>
<userPermissions>
<enabled>true</enabled>
<name>ActivateContract</name>
</userPermissions>
The following snippet shows the incorrect structure that triggers the error — a tabVisibilities element appears after a userPermissions block, breaking the required consecutive grouping:
<tabVisibilities>
<tab>TestObject__c</tab>
<visibility>DefaultOn</visibility>
</tabVisibilities>
<userPermissions>
<enabled>true</enabled>
<name>ActivateContract</name>
</userPermissions>
<tabVisibilities>
<tab>TestObject2__c</tab>
<visibility>DefaultOn</visibility>
</tabVisibilities>
In Salesforce Metadata API, when a Profile XML file contains multiple occurrences of the same element type (such as tabVisibilities, userPermissions, fieldPermissions, and others), all occurrences of that element must be grouped together consecutively in the XML file. They cannot be split apart by other element types.
To resolve the error:
Note: This rule only applies when there are multiple occurrences of the same element type. A Profile with only a single `` element is not affected.
000383335

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.