12

I am trying to retrieve the layouts of all(standard + custom) objects from a test Enterprise org using package.xml manifest files. There are some customs objects that I have created on this org.

There is a managed package(SalesForece Google Ads,SFGA) installed in this org. This packages contains some customs objects also e.g

SFGA__Ad_Group__c
SFGA__Google_Campaign__c
SFGA__Keyword__c
SFGA__Search_Phrase__c
SFGA__Text_Ad__c
SFGA__Version_33_0_3__c

My package.xml manifest file tries to fetch layouts. File looks like

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

In response I get the layouts of standard objects and the custom objects that i created myself. However I do NOT get the layouts of custom objects that belong to that managed package. How can I get the layout of custom objects that belong to a managed package?

Also, will I be able to change the layouts? I know I can change the layouts for standard ones and the ones that i created myself.

  • auny, my mistake, seems this does not apply to layouts. I can download these through eclipse. So you should be able to with ANT. Each package has its own package.xml... – dacology Jul 10 '13 at 14:30
  • Which API or method are you talking about? Can you elaborate on the usage of API? – auny Jul 10 '13 at 15:34
  • You can use the packageNames attribute in your build.xml file to query the layouts for a managed package (e.g. SFGA). This will cause the objects and layouts to be downloaded from that package. You can then modify the layouts and upload your changes. – sfdcfox Jul 10 '13 at 16:07
  • Did you mean to say package.xml when you said build.xml? So from your comment i take that changes can be done on layouts from 3rd party managed packages. I initially thought that it would not be possible – auny Jul 10 '13 at 18:22
21

To fetch objects from a managed package using the unmanaged package.xml, you need to explicitly call for each object, as the wildcard only retrieves objects outside a package.

To retrieve layouts you need to include the full (namespaced) object name before the hyphen, and the full (namespaced) layout name after the hyphen.

So for a packaged layout over a standard object you need to retrieve

<Object Name>-<namespace>__<Layout Name>

and for a packaged layout over a packaged object

<namespace>__<Object Name>-<namespace>__<Layout Name>

I have used the Salesforce for Social Media app as an example.

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
   <types>
        <members>Campaign-sf4twitter__Campaign Layout</members>
        <members>Case-sf4twitter__SfSocial Case Layout</members>
        <members>Contact-sf4twitter__SfSocial Contact Layout</members>
        <members>Lead-sf4twitter__SfSocial Lead Layout</members>
        <members>sf4twitter__Fcbk_Page_Admin__c-sf4twitter__Facebook Page Admin Layout</members>
        <members>sf4twitter__Fcbk_Page__c-sf4twitter__FCBK Page Layout</members>
        <members>sf4twitter__Fcbk_User__c-sf4twitter__FCBK User Layout</members>
        <members>sf4twitter__Twitter_Account__c-sf4twitter__Twitter Account Layout</members>
        <members>sf4twitter__Twitter_Contributor__c-sf4twitter__Twitter Contributor Layout</members>
        <members>sf4twitter__Twitter_Conversation__c-sf4twitter__Conversation Layout</members>
        <members>sf4twitter__Twitter_Followers__c-sf4twitter__Twitter Follower Layout</members>
        <members>sf4twitter__Twitter_Scheduler__c-sf4twitter__Twitter_Scheduler Layout</members>
        <members>sf4twitter__Twitter_Search__c-sf4twitter__Twitter Search Layout</members>
        <name>Layout</name>
   </types>
   <version>27.0</version>
</Package>

If you retrieve profiles at the same time then these profiles will also include the layout assignments.

You can also use an ant list call to retrieve the names of all layouts to use in your package.xml with one major caveat. The list metadata call drops the second namespace, so you'll get sf4twitter__Twitter_Search__c-Twitter Search Layout instead of sf4twitter__Twitter_Search__c-sf4twitter__Twitter Search Layout

  • The problem is that I do not know the names of the customs objects and their respective managed packages in advance. – auny Jul 23 '13 at 18:32
  • You should be able to use listMetadata to obtain a list of layouts. – sfdcfox Jul 23 '13 at 22:05
  • 3
    <target name="list-layouts"> <!-- Retrieve the contents into another directory --> <sf:listMetadata username="${sf.sbu}" password="${sf.sbp}" serverurl="${sf.sbs}" resultFilePath="Layout" metadataType="Layout" /> </target> – sfdcfox Jul 23 '13 at 22:07
  • The result will be a file that describes the name of each layout, even those in managed packages: FileName: layouts/... I recommend a Perl or Ruby script to parse the output into an XML file for you to copy/paste into your package.xml file. – sfdcfox Jul 23 '13 at 22:08
  • You Saved my day, even Mavensmate has this bug, we can select the page layout, but it doesn't retrieve. – Ankuli Jul 15 '16 at 14:57
0

You can retrieve all components if you know package name

<target name="retrieve">
  <sf:retrieve 
    username="${sf.username}" 
    password="${sf.password}" 
    sessionId="${sf.sessionId}" 
    serverurl="${sf.serverurl}" 
    maxPoll="${sf.maxPoll}" 
    retrieveTarget="/Users/mavensMate/" 
    packageNames="Zuora Quotes"/>
</target>

Script will return package.xml, where under namespacePrefix you can get prefix name and just append to all needed componets:

<namespacePrefix>zqu</namespacePrefix>

From

    <members>Quote__c-Quote Layout - Renewal V8%2E0</members>
        ...
    <name>Layout</name>
</types>

To

    <members>zqu__Quote__c-zqu__Quote Layout - Renewal V8%2E0</members>
        ...
    <name>Layout</name>
</types>

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.