Loading

'Error parsing file: Element x is duplicated at this location in type Profile' error

Дата публикации: Oct 13, 2022
Описание
We receive error "Error parsing file: Element X is duplicated at this location in type Profile" when trying to change the sequence of one of the attributes in the XML file of specific component in Metadata API. In this case, the specific component is Profile but this is applicable to any entity.

For example:

If we have metadata file retrieved for Profile, in metadata file you can see <tabvisibilities> section is at the starting like this :
<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>
 


So if we modify this as follows and just update same or new <tabvisibilities> section somewhere at the end of the file and then deploy the metadata file it throws error:

"Error parsing file: Element tabVisibilities is duplicated at this location in type Profile"
 

<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>
Решение
A field can have multiple occurrences in XML file. All of those fields must be specified together as a group and not be broken up by other fields. This is working as designed.

Fields that are different with in same ComplexType, for example: TabVisbilities, UserPermissions etc., all the fields of same name must be grouped together else the schema fails and throws an error just like what is happening in this case. 

This rule applies only in the case where we have multiple occurrences. For example: TabVisbilities there are multiple occurrences , but if you just have one TabVisibility field then that should not be an issue. So this should be the same behavior with other fields too. 
Номер статьи базы знаний

000383335

 
Загрузка
Salesforce Help | Article