2

I am using visual studio code to retrieve source from the org and then deploying changes in ant using the package.xml. Is there a way to grab the history field tragging flag for the standard field "owner" on my custom object? Owner doesn't seem to be listed as a field on the object..

3 Answers 3

4

OwnerId is a system field that is not retrievable by the metadata API.

However you can still deploy the history tracking property. In your custom object xml file, just add the following:

<fields>
    <fullName>OwnerId</fullName>
    <trackHistory>true</trackHistory>
</fields>
6
  • Would that be the {custom object name}.object-meta.xml file? Can I place it anywhere? How would I deploy that in the package.xml after?
    – JJ Sunga
    Jun 11, 2020 at 14:47
  • Yes. You can see the sample xml file here: developer.salesforce.com/docs/atlas.en-us.api_meta.meta/… How to deploy your metadata using workbench: help.salesforce.com/… Jun 11, 2020 at 15:01
  • Sorry, my previous comment has an incorrect info. If your custom object xml file is in the format of {custom object name}.object-meta.xml, that means it is sfdx format, you need to convert it to metadata api format first then you can deploy it using mdapi (eg; using workbench). Jun 11, 2020 at 15:16
  • is there a way to deploy that through the metadata api. How we handle it is that we currently only deploy through the metadata api using jenkins
    – JJ Sunga
    Jun 11, 2020 at 15:24
  • You are diverging from your original question. Anyway, using Jenkins or any tool, if you use mdapi, you need to follow the mdapi format. Jun 11, 2020 at 16:15
0

When two objects are in the master-detail relationship field, You will not have owner field on child object i.e. detail side of the relationship. The owner of the master record will be the owner of the child records. This is the reason Owner doesn't seem to be listed as a field on the object.

0

This can also be done directly in the SFDX.

You just need to create an additional metadata file in the object folder:
/objectName/fields/OwnerId.field-meta.xml

<?xml version="1.0" encoding="UTF-8"?>
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
    <fullName>OwnerId</fullName>
    <trackHistory>true</trackHistory>
</CustomField>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .