2

I am trying my hand at building a package.xml dynamically to download everything from an salesforce org, so I started the Novel approach of getting the describeMetadata and iterating through it to build my retrieve request! But soon discovered this would miss out on certain elements, one was, the EmailTemplate folders. (found a solution for that by firing a query to the Folder object filter by Type = Email, as even though the documentation say's if you retrieve a listMetadata on 'EmailTemplates', it returns the list of folders like reports, but it only returns a null )

I thought this was a one off, but .... ran into another one right now, that there is no element representing 'PageLayouts' in the describeMetadata Response .. what am I missing here ?

I am sure I am missing something obvious here, as there has to be a solutions for all the elements which I can get from eclipse while downloading a project but don't show up in describeMetadata for the org ?

for the retrieve of PageLayouts I have tried the following arguments.

 type: 'Layout',
 folder: 'layouts'

Didn't work!

UPDATE : 23/09/2014

Answer,

I was able to resolve this particular problem by using type = 'Layout' and leaving folder 'blank', which returns all the layouts for all the objects.

2

An easier way to accomplish this might be to use unmanaged packages to group the metadata you want to retrieve. In the org, go to Setup -> Create -> Packages and create an unmanaged package. Then add all the metadata you want to retrieve into it. One nice thing is that adding metadata spiders through its dependencies and includes them in the package too.

To clarify, you never upload the unmanaged package. You're just using the package as basically a container inside the org.

When you retrieve, retrieve with the packageName attribute. For example, in the Force.com Ant Migration Tool, you could do this:

  <sf:retrieve 
    username="${sf.username}" 
    password="${sf.password}" 
    serverurl="${sf.serverurl}" 
    retrieveTarget="DIRECTORY_PATH" 
    packageNames="PACKAGE_NAME_HERE"/>

When you pass a package name, you don't have to provide a package.xml as a manifest for the retrieve. Everything in the package is retrieved automatically. The package.xml file you get will be entirely explicit. It lists every item of metadata including metadata subtypes contained inside a single file like CustomField and WebLink.

I covered this approach, which I call Local Unmanaged Packages, in this Dreamforce presentation starting at about 11:15... http://dreamforce.vidyard.com/watch/qWZdC_n0I8OagLzg_RJmIA

  • My Usecase is slightly different, I do not have an option to modify contents of the org from which I would like to retrieve the metadata. – Gunish Nov 8 '14 at 11:52
0

There is describeLayout() method that returns all layout of given object.

Syntax

DescribeLayoutResult = connection.describeLayout(string sObjectType, string layoutName, ID recordTypeID[]);

Here is Java sample code.

  String objectToDescribe = "Account";
  DescribeLayoutResult dlr = 
      connection.describeLayout(objectToDescribe, null, null);
  System.out.println("There are " + dlr.getLayouts().length +
      " layouts for the " + objectToDescribe + " object."
  );

Once you get list of objects you can iterate over the it and for each sobject call describeLayout() to fetch the list of all layouts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.