2

I'm trying to prepare a package for use with the Metadata API, and basically I just need the information like the Label, Full Name, and so on, without the List Views, Custom Fields, and so on. Is there an easy way to export just the basic information for CustomObject? I need to do this for about 150 objects, and preferably in an automated manner, since I'll likely need to do this many different times.

Example desired result:

<?xml version="1.0" encoding="UTF-8"?>
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
    <deploymentStatus>Deployed</deploymentStatus>
    <description>test object with one field for eclipse ide testing</description>
    <label>MyFirstObject</label>
    <nameField>
        <label>MyFirstObject Name</label>
        <type>Text</type>
    </nameField>
    <pluralLabel>MyFirstObjects</pluralLabel>
    <sharingModel>ReadWrite</sharingModel>
</CustomObject>

As far as I can tell, by default, when you mention a CustomObject in a package.xml, it includes all fields, list views, compact layouts, record types, search layouts, and so on, when I really just want the basic top-level details.

The purpose is that I want to be able to deploy the object's basic definitions, and then deploy a combination of custom fields as a separate deployment. We far more than the allowed 5,000 objects in the Metadata API, so we need to break the deployment into various pieces.

2
  • Would you accept a solution in ANT script with some regex to keep only the information your need ?
    – brovasi
    Commented Dec 15, 2016 at 21:18
  • @CloudNinja Yes, something automated would be ideal if you know of a way to do so. I'm not well versed in writing Ant's version of JS, so it's a task that would take me a while to get through.
    – sfdcfox
    Commented Dec 15, 2016 at 21:35

3 Answers 3

0

I don't really know if you can configure more granular access to the subelements of a custom object, via the 'subscribe to metadata' dialog, or through the package.xml. That would be a nice feature.

However, to answer your question, I'd recommend writing an XML utility to remove whatever elements you are not interested in. If you are good with DOM, XLST, or linq-to-XML in C#, this is not too hard.

0

I used regex in the past to delete SociaPersona references from all profiles in ANT script (because salesforce didn't always like when you deploy this kind of elements). Now it's not a tested version but I think you could do the same thing with any other tags, here is an example with fields.

The following regex works for me in sublime :

\s*<fields[\s\S]*?<\/fields>

build.xml code :

<target name="delete_fields_tags">
    <replaceregexp match="\s*&lt;fields[\s\S]*?&gt;\/fields&gt;" replace="" flags="gm" byline="false">
        <fileset dir="..\..\src\objects" includes="**/*.xml" />
    </replaceregexp>
</target>

<target name="deploy_metadata" depends="delete_fields_tags">
    <echo message="Connecting to..." />
    <echo message="***Username = ${sf.deploy.username}" />
    <echo message="***Password = **************************" />
    <echo message="***Server URL = ${sf.deploy.serverurl}" />
    <sf:deploy username="${sf.deploy.username}" password="${sf.deploy.password}" serverurl="${sf.deploy.serverurl}" deployRoot="..\..\src" maxPoll="${sf.maxPoll}" pollWaitMillis="${sf.pollWaitMillis}"  runAllTests="${sf.runAllTests}" />
</target>

Hope that can help

0

Well - You can certainly do it but only if the payload is somewhat smaller.

You can use Eclipse IDE

After creating a new Force.com project and connecting to your source instance, click on the selected Metadata components and choose

You can select custom or standard objects

The LineItem object here has ListViews, Validation Rules, Workflow rules etc.

Click on the custom field checkbox and you will get to move just those fields like you wanted.

You can do the same for multiple objects at the same time. And if you need to do this multiple times, save the package.xml

Hope this helps!

You must log in to answer this question.

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