1

I tried to use package.xml in Visual Studio Code, when I retrieve it, it give me the error in the screen shot.

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

enter image description here

I also tried using workbench to deploy a new ManagedContentType,

The package.xml I used:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>engBlog</members>
        <name>ManagedContentType</name>
    </types>
    <version>47.0</version>
</Package>

The custom contenttype xml:

<?xml version="1.0" encoding="UTF-8"?>
<ManagedContentType xmlns="http://soap.sforce.com/2006/04/metadata">
    <description>Engineering blogs published on salesforce.com/devblog</description>
    <developerName>engBlog</developerName>
    <managedContentNodeTypes>
        <helpText>Title to be shown in the blog post</helpText>
        <isLocalizable>true</isLocalizable>
        <isRequired>true</isRequired>
        <nodeLabel>Blog Title</nodeLabel>
        <nodeName>title</nodeName>
        <nodeType>NAMEFIELD</nodeType>
        <placeholderText>Enter an SEO friendly title...</placeholderText>
    </managedContentNodeTypes>
    <managedContentNodeTypes>
        <helpText>Main image that's shown at the top of the blog post</helpText>
        <isLocalizable>false</isLocalizable>
        <isRequired>false</isRequired>
        <nodeLabel>Primay Image</nodeLabel>
        <nodeName>primaryImage</nodeName>
        <nodeType>IMG</nodeType>
    </managedContentNodeTypes>
    <managedContentNodeTypes>
        <helpText>Blog's main body</helpText>
        <isLocalizable>true</isLocalizable>
        <isRequired>true</isRequired>
        <nodeLabel>Main Content</nodeLabel>
        <nodeName>body</nodeName>
        <nodeType>RTE</nodeType>
    </managedContentNodeTypes>
    <managedContentNodeTypes>
        <isLocalizable>true</isLocalizable>
        <isRequired>false</isRequired>
        <nodeLabel>Excerpt</nodeLabel>
        <nodeName>excerpt</nodeName>
        <nodeType>MTEXT</nodeType>
    </managedContentNodeTypes>
    <managedContentNodeTypes>
        <helpText>Shown as a tag text when a preview is rendered</helpText>
        <isLocalizable>true</isLocalizable>
        <isRequired>true</isRequired>
        <nodeLabel>Category</nodeLabel>
        <nodeName>category</nodeName>
        <nodeType>TEXT</nodeType>
    </managedContentNodeTypes>
    <managedContentNodeTypes>
        <isLocalizable>true</isLocalizable>
        <isRequired>false</isRequired>
        <nodeLabel>Author Name</nodeLabel>
        <nodeName>authorName</nodeName>
        <nodeType>TEXT</nodeType>
    </managedContentNodeTypes>
    <managedContentNodeTypes>
        <isLocalizable>true</isLocalizable>
        <isRequired>false</isRequired>
        <nodeLabel>Date to Show</nodeLabel>
        <nodeName>date</nodeName>
        <nodeType>TEXT</nodeType>
        <placeholderText>Enter human readable date</placeholderText>
    </managedContentNodeTypes>
    <managedContentNodeTypes>
        <helpText>Blog's footer</helpText>
        <isLocalizable>true</isLocalizable>
        <isRequired>true</isRequired>
        <nodeLabel>Footer content</nodeLabel>
        <nodeName>footer</nodeName>
        <nodeType>RTE</nodeType>
    </managedContentNodeTypes>
    <masterLabel>Blog</masterLabel>
</ManagedContentType>

after I get a SUCCESS response,

enter image description here

I tried to query it from workbench, but the results only return a News type. enter image description here

1

You can retrieve the managed content type by adding ManagedContentType as a type in package.xml

Sample example

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>*</members>
        <name>ManagedContentType</name>
    </types>
    <types>
        <members>news</members>
        <name>ManagedContentType</name>
    </types>
    <version>47.0</version>
</Package>
3
  • Thanks, I do use that before in visual code with salesforce DX, but it keeps giving me: "ERROR running force:source:retrieve: Cannot read property 'metadataName' of undefined"
    – Kuan
    Mar 15 '20 at 0:49
  • 1
    can you try retrieving the metadata from workbench using this package.xml, just to be sure if this is a problem with package.xml or your sfdx installation? Also, I would recommend opening an issue at github.com/forcedotcom/cli/issues if it works from workbench
    – swati
    Mar 15 '20 at 3:17
  • I tried workbench, it can successfully retrieve the news managedContentType and download as package zip file, but the salesforce DX can retrieve other type of custom object(only this managedcontenttype metadata failed to retrieve), I guess I can live with workbench for now, BTW, could you give a little bit more detail about how to DEPLOY a new ManagedContentType member( for example, I create a new managedcontenttype as Blog)? Thanks
    – Kuan
    Mar 15 '20 at 6:46
1

First of all, it would be great if you could get familiar with Deploying and Retrieving Metadata. Also, have a look at sample package.xml files:

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

A CustomObject here is a name of your metadata type you try to retrieve/deploy. An Account is the API Name of one of custom objects that can be retrieved from an Org. A default API Name for a custom object called, let's say, My Custom Object will be My_Custom_Object__c.

Similarly, if you want to retrieve/deploy a ManagedContentType, you must know its API Name. To use this metadata type, put it into package.xml:

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

How to get the API Name? Some ways of how to do that:

  1. Run a SOQL Query on ManagedContentType: SELECT MasterLabel, DeveloperName FROM ManagedContentType:
    • MasterLabel will help you identify your content type easily
    • DeveloperName is what you're looking for
  2. Retrieve all the metadata of this type using a * wildcard. Filenames of retrieved metadata will corespond to its DeveloperName which you can now use to use only specific records. Also, you can get it from their contents - described below.

If you want to deploy a newly created Custom Content Type - its API Name hides between <developerName> tags.

For instance, using an example from Create Custom Contect Type for Salesforce CMS Docs:

<?xml version="1.0" encoding="UTF-8"?>
<ManagedContentType xmlns="http://soap.sforce.com/2006/04/metadata">
    <description>Engineering blogs published on salesforce.com/devblog</description>
    <developerName>engBlog</developerName>
    <managedContentNodeTypes>
        <helpText>Title to be shown in the blog post</helpText>
        <isLocalizable>true</isLocalizable>
        <isRequired>true</isRequired>
        <nodeLabel>Blog Title</nodeLabel>
        <nodeName>title</nodeName>
        <nodeType>NAMEFIELD</nodeType>
        <placeholderText>Enter an SEO friendly title...</placeholderText>
    </managedContentNodeTypes>
    <managedContentNodeTypes>
        <helpText>Main image that's shown at the top of the blog post</helpText>
        <isLocalizable>false</isLocalizable>
        <isRequired>false</isRequired>
        <nodeLabel>Primay Image</nodeLabel>
        <nodeName>primaryImage</nodeName>
        <nodeType>IMG</nodeType>
    </managedContentNodeTypes>
    <managedContentNodeTypes>
        <helpText>Blog's main body</helpText>
        <isLocalizable>true</isLocalizable>
        <isRequired>true</isRequired>
        <nodeLabel>Main Content</nodeLabel>
        <nodeName>body</nodeName>
        <nodeType>RTE</nodeType>
    </managedContentNodeTypes>
    <managedContentNodeTypes>
        <isLocalizable>true</isLocalizable>
        <isRequired>false</isRequired>
        <nodeLabel>Excerpt</nodeLabel>
        <nodeName>excerpt</nodeName>
        <nodeType>MTEXT</nodeType>
    </managedContentNodeTypes>
    <managedContentNodeTypes>
        <helpText>Shown as a tag text when a preview is rendered</helpText>
        <isLocalizable>true</isLocalizable>
        <isRequired>true</isRequired>
        <nodeLabel>Category</nodeLabel>
        <nodeName>category</nodeName>
        <nodeType>TEXT</nodeType>
    </managedContentNodeTypes>
    <managedContentNodeTypes>
        <isLocalizable>true</isLocalizable>
        <isRequired>false</isRequired>
        <nodeLabel>Author Name</nodeLabel>
        <nodeName>authorName</nodeName>
        <nodeType>TEXT</nodeType>
    </managedContentNodeTypes>
    <managedContentNodeTypes>
        <isLocalizable>true</isLocalizable>
        <isRequired>false</isRequired>
        <nodeLabel>Date to Show</nodeLabel>
        <nodeName>date</nodeName>
        <nodeType>TEXT</nodeType>
        <placeholderText>Enter human readable date</placeholderText>
    </managedContentNodeTypes>
    <managedContentNodeTypes>
        <helpText>Blog's footer</helpText>
        <isLocalizable>true</isLocalizable>
        <isRequired>true</isRequired>
        <nodeLabel>Footer content</nodeLabel>
        <nodeName>footer</nodeName>
        <nodeType>RTE</nodeType>
    </managedContentNodeTypes>
    <masterLabel>Blog</masterLabel>
</ManagedContentType>

... Your package.xml should look like this:

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>engBlog</members>
        <name>ManagedContentType</name>
    </types>
    <version>47.0</version>
</Package>
13
  • @Przemyslaw_tamori Thanks, I do use similar sample u gave here(I use * rather than engBlog) in visual code with salesforce DX, but it keeps giving me: "ERROR running force:source:retrieve: Cannot read property 'metadataName' of undefined"
    – Kuan
    Mar 15 '20 at 1:05
  • @Kuan can you edit your question and provide exact code of package.xml? Or is that the one it's already there? Mar 15 '20 at 9:02
  • @Przemyslaw_tamori I update the question post. Btw, I find a way to retrieve that managedcontenttype from workbench now, but I still can not find the new managedcontenttype as in your example(the engBlog) after the deploy, could you show me how to use workbench to deploy and retrieve the engBlog metadata type? Thanks
    – Kuan
    Mar 16 '20 at 11:43
  • @Kuan engBlog has been taken from an example I provided the link to. There are plenty of resources in web of how to use Workbench in order to work with metadata: Salesforce Docs for instance. Mar 16 '20 at 12:51
  • @Przemyslaw_tamori that is exact doc I followed to work with workbench, but after I deployed the engBlog package(it shows me success), I can not retrieve it using same package.xml( I can not even find ManagedContentType Object in SOQL page)
    – Kuan
    Mar 17 '20 at 9:29

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.