Folder

Represents a folder.

Five folder types currently exist in Salesforce:

  • Document folder
  • Email folder (available for Salesforce Classic email templates only)
  • Email Template folder
  • Report folder
  • Dashboard folder

Folder type names end with the “Folder” suffix. For example, the type name of a document folder is “DocumentFolder”.

Parent Type 

This type extends Metadata and inherits its fields.

File Suffix and Directory Location 

Folders are stored in the corresponding component directory of the package. These directories are named documents, email, emailTemplates, reports, and dashboards. Folders don’t have a text file representation—they’re containers for files. For each folder, an accompanying metadata file named FolderName.folderType-meta.xml is created at the same directory level. The FolderName.folderType-meta.xml metadata file contains the metadata information for that folder, such as the accessType. For example, for a documents folder named sampleFolder, there’s a sampleFolder.documentFolder-meta.xml within the documents folder of the package.

Fields 

accessType 

  • Type: FolderAccessTypes (enumeration of type string)
  • Required: No
  • Description: Required. The type of access for this folder.
  • Possible values:
    • Shared — . This folder is accessible only by the specified set of users.
    • Public — . This folder is accessible by all users, including portal users.
    • PublicInternal — . This folder is accessible by all users, excluding portal users. This setting is available for report and dashboard folders in organizations with a partner portal or Customer Portal enabled.
    • Hidden — . This folder is hidden from all users.

folderShares 

fullName 

  • Type: string
  • Required: No
  • Description: The name used as a unique identifier for API access. The fullName can contain only underscores and alphanumeric characters. It must be unique, begin with a letter, not include spaces, not end with an underscore, and not contain two consecutive underscores. This field is inherited from the Metadata component.

name 

  • Type: string
  • Required: Yes
  • Description: Required. The name of the document folder.

publicFolderAccess 

  • Type: PublicFolderAccess (enumeration of type string)
  • Required: No
  • Description: If Public is the value for accessType, this field indicates the type of access all users have to the contents of the folder. Valid values include:
  • Possible values:
    • ReadOnly — . All users can read the contents of the folder, but no user can change the contents.
    • ReadWrite — . All users can read or change the contents of the folder.

sharedTo 

Declarative Metadata Sample Definition 

The following is the package manifest definition of a document folder that contains a document:

1<?xml version="1.0" encoding="UTF-8"?>
2<Package xmlns="http://soap.sforce.com/2006/04/metadata">
3    <fullName>basic</fullName>
4    <types>
5        <members>sampleFolder</members>
6        <members>sampleFolder/TestDocument.txt</members>
7        <name>Document</name>
8    </types>
9    <version>68.0</version>
10</Package>

The following is an example of the sampleFolder-meta.xml metadata file for the sampleFolder document folder:

1<?xml version="1.0" encoding="UTF-8"?>
2<DocumentFolder xmlns="http://soap.sforce.com/2006/04/metadata">
3    <accessType>Public</accessType>
4    <name>sampleFolder</name>
5    <publicFolderAccess>ReadWrite</publicFolderAccess>
6</DocumentFolder>

Deploying or Retrieving Nested Folders 

To deploy or retrieve only a nested folder component, and not its contents, you must use a specific syntax in your package.xml. To reference the nested folder itself, append a trailing slash (/) to its full name in the <members> tag.

For example, to retrieve a nested DocumentFolder named MyNestedFolder located inside MyTopFolder, your package.xml must list the member with a trailing slash (/).

1<?xml version="1.0" encoding="UTF-8"?>
2<Package xmlns="http://soap.sforce.com/2006/04/metadata">
3 <types>
4 <members>MyTopFolder/MyNestedFolder/</members>
5 <name>DocumentFolder</name>
6 </types>
7 <version>58.0</version>
8</Package>

If you omit the trailing slash (for example, <members>MyTopFolder/MyNestedFolder</members>), the operation fails. The API incorrectly searches for a Document component named MyNestedFolder instead of the folder.

This syntax applies to all folder types. For ReportFolder, you must use the Report type in the manifest. For Lightning Email Template folders, use the EmailTemplateFolder type.

Version 

Folders are available in API version 11.0 and later.

Wildcard Support in the Manifest File 

This metadata type doesn’t support the wildcard character * (asterisk) in the package.xml manifest file. For information about using the manifest file, see Deploying and Retrieving Metadata with the Zip File.