[SalesForce] Ant – How to deploy a custom field on an “installed app”

We're using Conga Composer. We've added a custom field to the class "APXTConga4__Conga_Template__c" called "Template_Call_Method__c". It's a picklist.

When I deploy to a new org I have to be able to add this field to the APXTConga4__Conga_Template__c object, otherwise dependencies will fail, the most obvious being any permissions that rely on this field.

I already have CustomObjects defined in package.xml as this:

<types>
    <members>*</members>
    <name>CustomObject</name>
</types>

And I've tried adding the field to CustomFields:

<types>
    <members>*</members>
    <members>APXTConga4__Conga_Template__c.Template_Call_Method__c</members>
    .
    .
    .
    <name>CustomField</name>
</types>

However, when I try to deploy this I get the following error:

objects/APXTConga4__Conga_Template__c.object -- Error: Must specify a non-empty label for the CustomObject
[+ consequent errors]

Edit to add:
If I try and add the whole Conga object to the package manifest as follows:

<types>
    <members>*</members>
    <members>APXTConga4__Conga_Template__c</members>
    <name>CustomObject</name>
</types>

Then I get this error:

objects/APXTConga4__Conga_Template__c.object -- Error: Cannot modify object: entity=CustomEntityDefinition, component=01I20000000tcgu, field=Description, state=MANAGED_INSTALLED: newValue='Merge template manager for use with Conga Composer and Conga Mail Merge.', oldValue='Template Manager for use with Conga Composer and Conga Mail Merge.'

Ie, as expected, its a managed package, you can't mess with it.

So how can I deploy the custom field to this object using ant?

Best Answer

If you are deploying a CustomField onto an object provided by another managed package, you cannot include the CustomObject in your package.xml and you need instead list the CustomField in the package.xml. If you change your package.xml to this it should work:

<types>
   <members>APXTConga4__Conga_Template__c.Template_Call_Method__c</members.
   <name>CustomField</name>
</types>

We do something similar in one of our packages which extends another managed package. You can see the object definition and the full package.xml file at the links below. The package.xml lists the CustomField but does not list the npo02__Household__c CustomObject.

https://github.com/SalesforceFoundation/Cumulus/blob/dev/src/objects/npo02__Household__c.object https://github.com/SalesforceFoundation/Cumulus/blob/dev/src/package.xml

Note that we use a very explicit package.xml with no wildcards so I'm not sure if your wildcard for CustomObject will include the APXTConga4__Conga_Template__c CustomObject or not. If you get the same error, you might have to explicitly list out your CustomObjects and exclude the Conga object from the members.