function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SabinaSabina 

SFDX Push Error: An object 'Account.ParentId' of type CustomField was named in package.xml, but was not found in zipped directory

Hello,

I created a scratch orgs without problems and now I am trying to push the source from the local branch.
I am getting 68 errors of this type:
An object 'Account.ParentId' of type CustomField was named in package.xml, but was not found in zipped directory
All the mentioned fields are in the sfdx project source under main/default/objects/Account/fields and the scratch org API version matches the project one. 
Could anyone help me understand what I'm doing wrong, please?

Many thanks!
Sabina
 
Best Answer chosen by Sabina
SabinaSabina
Salesforce support sent me this article (https://help.salesforce.com/articleView?id=000321246&language=en_US&type=1&mode=1) and it helped me understand the issue. 
This is currently a limitation of the packaging framework and the metadata API. The same object cannot be referenced in multiple packageDirectories

I use the sfdx-falcon template (https://github.com/sfdx-isv/sfdx-falcon-template/tree/master/sfdx-source) with separate folders for the packaged components (part of our AppExchange app) and unpackaged components (configuration used for testing and quick org setup). And I had the Account and Contact objects split in the two folders as follows:

/namespace
--/Account
----/fields
------ (all the fields that we package)
/unpackaged
--/Account
----/fields
------ (all the other fields)

And this caused the failure. Once I removed the /fields, /listviews, and other folders from unpackaged > Account, the push worked.
I could still keep the Account.object-meta.xml file in unpackaged > Account and the rest in namespace > Account. This helps us set default Account record pages when creating scratch orgs, instead of having to manually drag the components onto the page every time.

I hope this helps.

All Answers

Shivi Srivastava 30Shivi Srivastava 30
Hi Sabina,

Did you get the reolution for this? I am also facing similar issue and not sure if it is able to identify package.xml path.

Thanks!
SabinaSabina
Hi Shivi, I am not entirely sure, but somehow I made it work that day (haven't tried it since). My assumption is that removing the standard field references from the profile and permission set files helped. 
Shivi Srivastava 30Shivi Srivastava 30
Yeah Thanks Sabina, I figured out the issue. Thanks!
Roarke Lynch 12Roarke Lynch 12
Shivi -- was your solutino what Sabina described or something different?
Ankush02Ankush02
Hi All, 

To fix the above issue, check if the xml file name is matching the api file name. For example

If Phone is the custom field as below.
<?xml version="1.0" encoding="UTF-8"?>
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
    <fullName>Phone</fullName>
    <trackFeedHistory>false</trackFeedHistory>
</CustomField>

We need to make sure, the xml file name is as below:
Phone.field-meta.xml.

It goes for all the custom fields API name and their meta.xml files.

Hope this helps.

Regards,
Ankush
 
SabinaSabina
Hi Ankush,

I keep getting these errors unfortunately. I checked, and we have all the needed XML files. But it still doesn't work. 
I have already opened my third case on the topic with Salesforce. But they keep closing them :) 
Will keep this thread updated if I get any useful information.

Thanks,
Sabina
Kimberly SullivanKimberly Sullivan

Hi Sabina, 

Any chance you've heard back on your case? (or figured out the problem?) I'm getting the same errors and also opened a case but haven't heard anything yet. 

Thank you,
Kim

SabinaSabina
Hi Kim, I have a call with them later today to demo the issue, but I don't expect they will come with a solution right away. Will let you know once (if) I have it.
SabinaSabina
Salesforce support sent me this article (https://help.salesforce.com/articleView?id=000321246&language=en_US&type=1&mode=1) and it helped me understand the issue. 
This is currently a limitation of the packaging framework and the metadata API. The same object cannot be referenced in multiple packageDirectories

I use the sfdx-falcon template (https://github.com/sfdx-isv/sfdx-falcon-template/tree/master/sfdx-source) with separate folders for the packaged components (part of our AppExchange app) and unpackaged components (configuration used for testing and quick org setup). And I had the Account and Contact objects split in the two folders as follows:

/namespace
--/Account
----/fields
------ (all the fields that we package)
/unpackaged
--/Account
----/fields
------ (all the other fields)

And this caused the failure. Once I removed the /fields, /listviews, and other folders from unpackaged > Account, the push worked.
I could still keep the Account.object-meta.xml file in unpackaged > Account and the rest in namespace > Account. This helps us set default Account record pages when creating scratch orgs, instead of having to manually drag the components onto the page every time.

I hope this helps.
This was selected as the best answer
Kallu KaliaKallu Kalia
Thanks
 
Fb Status in hindiFb Status in hindi
I recently found this site as it is so helpful. there are many times before searching a solution to my problem...For more....
User-added image
Fb Status hindi-----Whatsaap Status -----Attitude-status---------Gf-Bf Status -----Royal Status
Mark AchkarMark Achkar
Hello,
I had the same issue. The problem is having a Custom Object  with the same name as a Custom Field that belongs to it.
Before pushing, check the Folder of the Custom Object, and make sure it contains only 1 File with the name (having .object).
I had 1 file with .object, and 1 file .field .
Once I deleted the .field from the Folder (careful, from the Custom Object folder, and not the fields folder) the push worked well.

Goodluck
Robert howard 5Robert howard 5
I discovered your blog site on google and check a few of your early posts. Continue to keep up the very good operate. I just additional up your RSS feed to my MSN News Reader. Seeking forward to reading more from you later on!… http://goldentrip.bravesites.com https://www.deviantart.com
 
Ron ParrottRon Parrott
Recently came across an issue caused by a known bug where two different types of metadata with the same API name end up in the same folder after an sfdx force:org:pull (see bug report here: https://github.com/forcedotcom/cli/issues/602).

After "deleting" the metadata XML config files that were in the correct folder and inadvertently leaving the files created by the bug, I started getting this message. Eventually figured it out and removed those files as well which fixed the problem and my source pushed. Hopefully this is helpful in case someone else is in this boat while building a 2nd gen package.
Chandramohan Yetukuri 1Chandramohan Yetukuri 1
Even i have the same issue while deploying through Jenkins.Please help

Hello Friends...i have a below issue while deploying a new Apex xlass tbrough Jenkins fom git branch...

While deploying one apex class through Jenkins..i am getting the below error. Details are mentioned as below.


API Name            
ChandraApexClass    
Error Message
An object 'ChandraApexClass' of type ApexClass was named in package.xml, but was not found in zipped directory

package.xml
  
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>ChandraApexClass</members>
<name>ApexClass</name>
</types>
<version>51.0</version>
</Package>


Apex Class Name:-
ChandraApexClass.cls

Apex Class:-
public with sharing class ChandraApexClass {
public static void ApexClassDebug() {
List<Contact> contList = [Select Id, Name from Contact Limit 50];
for(Contact conts : contList)
{
System.Debug('Contact Name' + conts.Name);
//Test
System.Debug('Just To Test');
}
}
}
Abhirup SenguptaAbhirup Sengupta
Hi Team,

I was facing similar issue like this.
The problem is that SFDX follows a folder structure. If you or anyone have pushed a file incorrectly , we get this error.
Solution: 1. Search with the file name in any file explorer/VS Code project and see the directory it is in.
                2. Most definitely the file is not in the correct folder Ex- a field should be inside object/Object_name/fields/fieldname.field-meta.xml but                          mostly you might have pushed it incorrectly.
                3. Move the file in correct folder and push your code in repo/ git.
                4. Re-run your deployment.

Voila! your error is gone :)
Dileep Singhal 18Dileep Singhal 18
I have also faced same issue, To resolve it you need also check package xml file wherein you may have entered components in wrong locations Once you mark them on right place the issue will resolve. 
Lets consider one new apex classes you are moving but somehow it logged to APEXPAGES section in package xml file then you may come across with this type of errors while validatiing & deploymnets