[SalesForce] Not in package.xml error when deploying to Pricebook2 and PriceBookEntry with Ant Migration Tool

I have been successfully migrating fields between orgs using Ant by retrieving from source org and deploying to target org.

However, when I got to fields in Pricebook2 and PriceBookEntry, the retrieve was successful but the deploy fails with 'objects/Pricebook2.object (Pricebook2.New__c) — Error: Not in package.xml'. This was a simple Text(5) field.

Have tried creating a new field, copying name directly from definition page and pasting into package.xml so that there is no difference in case. Also checked field level security.

The actual field I'm trying to move is a text external id field to be used for data importing. I have succesfully retrieved and deployed a field with the same definition on Account, Contact and Opportunity.

Strange that the retrieve is successful but the deploy fails.

Anyone else experienced this?

As it's only a couple of fields I can create them manually but am interested in the cause of this.

Thanks,
Mike.

Best Answer

My guess is that your deployment manifest is missing the Pricebook2 custom object.


I was able to successfully create an external id text field named New__c on the Pricebook2 object in a developer org by making a metadata api deployment with the following contents:

./package.xml

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types> 
        <members>Pricebook2</members>
        <name>CustomObject</name>
    </types>
    <version>36.0</version>
</Package>

./objects/Pricebook2.object

<?xml version="1.0" encoding="UTF-8"?>
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
    <fields>
        <fullName>New__c</fullName>
        <externalId>true</externalId>
        <label>New</label>
        <length>5</length>
        <required>false</required>
        <trackTrending>false</trackTrending>
        <type>Text</type>
        <unique>false</unique>
    </fields>
</CustomObject>

I got an error message that said Pricebook2.New__c was not in package.xml when deploying:

./package.xml

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types> 
        <name>CustomObject</name>
    </types>
    <version>36.0</version>
</Package>

./objects/Pricebook2.object

<!-- Same as above -->
Related Topic