Class: Metadata

Metadata

new Metadata(conn)

Class for Salesforce Metadata API
Parameters:
Name Type Description
conn Connection Connection object
Source:

Classes

AsyncResultLocator
DeployResultLocator
RetrieveResultLocator

Members

pollInterval :Number

Polling interval in milliseconds
Type:
  • Number
Source:

pollTimeout :Number

Polling timeout in milliseconds
Type:
  • Number
Source:

Methods

checkDeployStatus(id, includeDetailsopt, callbackopt) → {Promise.<Metadata~DeployResult>}

Checks the status of declarative metadata call deploy()
Parameters:
Name Type Attributes Description
id String Async process id returned from previous deploy request
includeDetails Boolean <optional>
Sets the DeployResult object to include details information (default: false)
callback Callback.<Metadata~DeployResult> <optional>
Callback function
Source:
Returns:
Type
Promise.<Metadata~DeployResult>

checkRetrieveStatus(id, callbackopt) → {Promise.<Metadata~RetrieveResult>}

Checks the status of declarative metadata call retrieve() and returns the zip file contents
Parameters:
Name Type Attributes Description
id String Async process id returned from previous retrieve request
callback Callback.<Metadata~RetrieveResult> <optional>
Callback function
Source:
Returns:
Type
Promise.<Metadata~RetrieveResult>

checkStatus(ids, callbackopt) → {Metadata~AsyncResultLocator}

Checks the status of asynchronous metadata calls
Parameters:
Name Type Attributes Description
ids String | Array.<String> The asynchronous process ID(s)
callback Callback.<(Metadata~AsyncResult|Array.<Metadata~AsyncResult>)> <optional>
Callback function
Source:
Returns:
Type
Metadata~AsyncResultLocator

create(type, metadata, callbackopt) → {Promise.<(Metadata~SaveResult|Array.<Metadata~SaveResult>)>}

Synchronously adds one or more new metadata components to the organization.
Parameters:
Name Type Attributes Description
type String The type of metadata to create
metadata Metadata~MetadataInfo | Array.<Metadata~MetadataInfo> Metadata to create
callback Callback.<(Metadata~SaveResult|Array.<Metadata~SaveResult>)> <optional>
Callback function
Source:
Returns:
Type
Promise.<(Metadata~SaveResult|Array.<Metadata~SaveResult>)>

createAsync(type, metadata, callbackopt) → {Metadata~AsyncResultLocator}

Asynchronously adds one or more new metadata components to the organization.
Parameters:
Name Type Attributes Description
type String The type of metadata to create
metadata Metadata~MetadataInfo | Array.<Metadata~MetadataInfo> Metadata to create
callback Callback.<(Metadata~AsyncResult|Array.<Metadata~AsyncResult>)> <optional>
Callback function
Source:
Returns:
Type
Metadata~AsyncResultLocator

createSync(type, metadata, callbackopt) → {Promise.<(Metadata~SaveResult|Array.<Metadata~SaveResult>)>}

Synonym of Metadata#create().
Parameters:
Name Type Attributes Description
type String The type of metadata to create
metadata Metadata~MetadataInfo | Array.<Metadata~MetadataInfo> Metadata to create
callback Callback.<(Metadata~SaveResult|Array.<Metadata~SaveResult>)> <optional>
Callback function
Source:
Returns:
Type
Promise.<(Metadata~SaveResult|Array.<Metadata~SaveResult>)>

del(typeopt, metadata, callbackopt) → {Metadata~AsyncResultLocator}

Synonym of Metadata#delete().
Parameters:
Name Type Attributes Description
type String <optional>
The type of metadata to delete
metadata String | Metadata~MetadataInfo | Array.<String> | Array.<Metadata~MetadataInfo> The fullName of metadata or metadata info to delete. If it is passed in fullName, the type parameter should not be empty.
callback Callback.<(Metadata~AsyncResult|Array.<Metadata~AsyncResult>)> <optional>
Callback function
Deprecated:
  • Yes
Source:
Returns:
Type
Metadata~AsyncResultLocator

delete(type, fullNames, callbackopt) → {Promise.<(Metadata~SaveResult|Array.<Metadata~SaveResult>)>}

Synchronously deletes specified metadata components in the organization.
Parameters:
Name Type Attributes Description
type String The type of metadata to delete
fullNames String | Array.<String> The fullName of metadata to delete.
callback Callback.<(Metadata~SaveResult|Array.<Metadata~SaveResult>)> <optional>
Callback function
Source:
Returns:
Type
Promise.<(Metadata~SaveResult|Array.<Metadata~SaveResult>)>

deleteAsync(type, metadata, callbackopt) → {Metadata~AsyncResultLocator}

Asynchronously deletes specified metadata components in the organization.
Parameters:
Name Type Attributes Description
type String The type of metadata to delete
metadata String | Metadata~MetadataInfo | Array.<String> | Array.<Metadata~MetadataInfo> The fullName of metadata or metadata info to delete. If it is passed in fullName, the type parameter should not be empty.
callback Callback.<(Metadata~AsyncResult|Array.<Metadata~AsyncResult>)> <optional>
Callback function
Source:
Returns:
Type
Metadata~AsyncResultLocator

deleteSync(type, fullNames, callbackopt) → {Promise.<(Metadata~SaveResult|Array.<Metadata~SaveResult>)>}

Synonym of Metadata#delete().
Parameters:
Name Type Attributes Description
type String The type of metadata to delete
fullNames String | Array.<String> The fullName of metadata to delete.
callback Callback.<(Metadata~SaveResult|Array.<Metadata~SaveResult>)> <optional>
Callback function
Source:
Returns:
Type
Promise.<(Metadata~SaveResult|Array.<Metadata~SaveResult>)>

deploy(zipInput, optionsopt, callbackopt) → {Metadata~DeployResultLocator}

Deploy components into an organization using zipped file representations
Parameters:
Name Type Attributes Description
zipInput stream.Stream | Buffer | String Zipped file input source in readable stream, binary buffer or Base64-encoded string
options Object <optional>
Options used in deployment
Properties
Name Type Attributes Description
allowMissingFiles Boolean <optional>
Specifies whether a deploy succeeds even if files that are specified in package.xml but are not in the .zip file or not.
autoUpdatePackage Boolean <optional>
If a file is in the .zip file but not specified in package.xml, specifies whether the file should be automatically added to the package or not.
checkOnly Boolean <optional>
Indicates whether Apex classes and triggers are saved to the organization as part of the deployment (false) or not (true).
ignoreWarnings Boolean <optional>
Indicates whether a warning should allow a deployment to complete successfully (true) or not (false). Defaults to false.
performRetrieve Boolean <optional>
Indicates whether a retrieve() call is performed immediately after the deployment (true) or not (false).
purgeOnDelete Boolean <optional>
If true, the deleted components in the destructiveChanges.xml manifest file aren't stored in the Recycle Bin.
rollbackOnError Boolean <optional>
Indicates whether any failure causes a complete rollback (true) or not (false).
runAllTests Boolean <optional>
If true, all Apex tests defined in the organization are run.
runTests Array.<String> <optional>
A list of Apex tests to be run during deployment.
singlePackage Boolean <optional>
Indicates whether the specified .zip file points to a directory structure with a single package (true) or a set of packages (false).
callback Callback.<Metadata~AsyncResult> <optional>
Callback function
Source:
Returns:
Type
Metadata~DeployResultLocator

describe(versionopt, callbackopt) → {Promise.<Metadata~DescribeMetadataResult>}

Retrieves the metadata which describes your organization, including Apex classes and triggers, custom objects, custom fields on standard objects, tab sets that define an app, and many other components.
Parameters:
Name Type Attributes Description
version String <optional>
The API version for which you want metadata; for example, 29.0
callback Callback.<Metadata~DescribeMetadataResult> <optional>
Callback function
Source:
Returns:
Type
Promise.<Metadata~DescribeMetadataResult>

list(queries, versionopt, callbackopt) → {Promise.<Array.<Metadata~FileProperties>>}

Retrieves property information about metadata components in your organization
Parameters:
Name Type Attributes Description
queries Metadata~ListMetadataQuery | Array.<Metadata~ListMetadataQuery> The criteria object(s) specifing metadata to list
version String <optional>
The API version for which you want metadata; for example, 29.0
callback Callback.<Array.<Metadata~FileProperties>> <optional>
Callback function
Source:
Returns:
Type
Promise.<Array.<Metadata~FileProperties>>

read(type, fullNames, callbackopt) → {Promise.<Array.<(Metadata~MetadataInfo|Array.<Metadata~MetadataInfo>)>>}

Synchronously read specified metadata components in the organization.
Parameters:
Name Type Attributes Description
type String The type of metadata to read
fullNames String | Array.<String> full name(s) of metadata objects to read
callback Callback.<(Metadata~MetadataInfo|Array.<Metadata~MetadataInfo>)> <optional>
Callback function
Source:
Returns:
Type
Promise.<Array.<(Metadata~MetadataInfo|Array.<Metadata~MetadataInfo>)>>

readSync(type, fullNames, callbackopt) → {Promise.<Array.<(Metadata~MetadataInfo|Array.<Metadata~MetadataInfo>)>>}

Synonym of Metadata#read()
Parameters:
Name Type Attributes Description
type String The type of metadata to read
fullNames String | Array.<String> full name(s) of metadata objects to read
callback Callback.<(Metadata~MetadataInfo|Array.<Metadata~MetadataInfo>)> <optional>
Callback function
Source:
Returns:
Type
Promise.<Array.<(Metadata~MetadataInfo|Array.<Metadata~MetadataInfo>)>>

rename(type, oldFullName, newFullName, callbackopt) → {Promise.<Metadata~SaveResult>}

Rename fullname of a metadata component in the organization
Parameters:
Name Type Attributes Description
type String The type of metadata to delete
oldFullName String The original fullName of metadata
newFullName String The new fullName of metadata
callback Callback.<Metadata~SaveResult> <optional>
Callback function
Source:
Returns:
Type
Promise.<Metadata~SaveResult>

retrieve(request, callbackopt) → {Metadata~RetrieveResultLocator}

Retrieves XML file representations of components in an organization
Parameters:
Name Type Attributes Description
request Metadata~RetrieveRequest Options for determining which packages or files are retrieved
callback Callback.<Metadata~AsyncResult> <optional>
Callback function
Source:
Returns:
Type
Metadata~RetrieveResultLocator

update(type, updateMetadata, callbackopt) → {Promise.<(Metadata~SaveResult|Array.<Metadata~SaveResult>)>}

Synchronously updates one or more metadata components in the organization.
Parameters:
Name Type Attributes Description
type String The type of metadata to update
updateMetadata Metadata~MetadataInfo | Array.<Metadata~MetadataInfo> Updating metadata
callback Callback.<(Metadata~SaveResult|Array.<Metadata~SaveResult>)> <optional>
Callback function
Source:
Returns:
Type
Promise.<(Metadata~SaveResult|Array.<Metadata~SaveResult>)>

updateAsync(type, updateMetadata, callbackopt) → {Metadata~AsyncResultLocator}

Asynchronously updates one or more metadata components in the organization.
Parameters:
Name Type Attributes Description
type String The type of metadata to update
updateMetadata Metadata~UpdateMetadataInfo | Array.<Metadata~UpdateMetadataInfo> Updating metadata
callback Callback.<(Metadata~AsyncResult|Array.<Metadata~AsyncResult>)> <optional>
Callback function
Source:
Returns:
Type
Metadata~AsyncResultLocator

updateSync(type, updateMetadata, callbackopt) → {Promise.<(Metadata~SaveResult|Array.<Metadata~SaveResult>)>}

Synonym of Metadata#update().
Parameters:
Name Type Attributes Description
type String The type of metadata to update
updateMetadata Metadata~MetadataInfo | Array.<Metadata~MetadataInfo> Updating metadata
callback Callback.<(Metadata~SaveResult|Array.<Metadata~SaveResult>)> <optional>
Callback function
Source:
Returns:
Type
Promise.<(Metadata~SaveResult|Array.<Metadata~SaveResult>)>

upsert(type, metadata, callbackopt) → {Promise.<(Metadata~UpsertResult|Array.<Metadata~UpsertResult>)>}

Upserts one or more components in your organization's data.
Parameters:
Name Type Attributes Description
type String The type of metadata to upsert
metadata Metadata~MetadataInfo | Array.<Metadata~MetadataInfo> Upserting metadata
callback Callback.<(Metadata~UpsertResult|Array.<Metadata~UpsertResult>)> <optional>
Callback function
Source:
Returns:
Type
Promise.<(Metadata~UpsertResult|Array.<Metadata~UpsertResult>)>

upsertSync(type, metadata, callbackopt) → {Promise.<(Metadata~UpsertResult|Array.<Metadata~UpsertResult>)>}

Synonym of Metadata#upsert().
Parameters:
Name Type Attributes Description
type String The type of metadata to upsert
metadata Metadata~MetadataInfo | Array.<Metadata~MetadataInfo> Upserting metadata
callback Callback.<(Metadata~UpsertResult|Array.<Metadata~UpsertResult>)> <optional>
Callback function
Source:
Returns:
Type
Promise.<(Metadata~UpsertResult|Array.<Metadata~UpsertResult>)>

Type Definitions

AsyncResult

Type:
  • Object
Properties:
Name Type Attributes Description
done Boolean Indicates whether the call has completed or not
id String ID of the component being created, updated, deleted, deployed, or retrieved
state String The state four possible values: Queued, InProgress, Completed, and Error.
statusCode String <optional>
If an error occurred during the create(), update(), or delete() call, a status code is returned
message String <optional>
Message corresponding to the statusCode field returned
Source:

DeployResult

Type:
  • Object
Properties:
Name Type Attributes Description
id String ID of the component being deployed
checkOnly Boolean Indicates whether this deployment is being used to check the validity of the deployed files without making any changes in the organization or not
completedDate String Timestamp for when the deployment process ended
createdDate String Timestamp for when the deploy() call was received
details Array.<Object> <optional>
Provides the details of a deployment that is in-progress or ended, if includeDetails is set to true in checkDeployStatus() call
done Boolean Indicates whether the server finished processing the deploy() call for the specified id
errorMessage String <optional>
Message corresponding to the values in the errorStatusCode field
errorStatusCode String <optional>
If an error occurred during the deploy() call, a status code is returned, and the message corresponding to the status code is returned in the errorMessagefield
ignoreWarnings Boolean <optional>
Specifies whether a deployment should continue even if the deployment generates warnings
lastModifiedDate String Timestamp of the last update for the deployment process
numberComponentErrors Number The number of components that generated errors during this deployment
numberComponentsDeployed Number The number of components deployed in the deployment process
numberComponentsTotal Number The total number of components in the deployment
numberTestErrors Number The number of Apex tests that have generated errors during this deployment
numberTestsCompleted Number The number of completedApex tests for this deployment
numberTestsTotal Number The total number of Apex tests for this deployment
rollbackOnError Boolean <optional>
Indicates whether any failure causes a complete rollback or not. Default is true.
startDate String Timestamp for when the deployment process began
status String Indicates the current state of the deployment
success Boolean Indicates whether the deployment was successful or not
Source:

DescribeMetadataResult

Type:
  • Object
Properties:
Name Type Description
metadataObjects Array.<Object> One or more metadata components and their attributes
Properties
Name Type Description
childXmlNames Array.<String> List of child sub-components for this component
directoryName String The name of the directory in the .zip file that contains this component
inFolder Boolean Indicates whether the component is in a folder or not
metaFile Boolean Indicates whether the component requires an accompanying metadata file
suffix String The file suffix for this component
xmlName String The name of the root element in the metadata file for this component
organizationNamespace String The namespace of the organization
partialSaveAllowed Boolean Indicates whether rollbackOnError is allowed or not
testRequired Boolean Indicates whether tests are required or not
Source:

FileProperties

Type:
  • Object
Properties:
Name Type Attributes Description
type String The metadata type, such as CustomObject, CustomField, or ApexClass
createdById String ID of the user who created the file
createdByName String Name of the user who created the file
createdDate String Date and time when the file was created
fileName String Name of the file
fullName String The file developer name used as a unique identifier for API access
id String ID of the file
lastModifiedById String ID of the user who last modified the file
lastModifiedByName String Name of the user who last modified the file
lastModifiedDate String Date and time that the file was last modified
manageableState String <optional>
Indicates the manageable state of the specified component if it is contained in a package
namespacePrefix String <optional>
The namespace prefix of the component
Source:

ListMetadataQuery

Type:
  • Object
Properties:
Name Type Attributes Description
type String The metadata type, such as CustomObject, CustomField, or ApexClass
folder String <optional>
The folder associated with the component.
Source:

MetadataInfo

Type:
  • Object
Properties:
Name Type Description
fullName String The name of the component
Source:

RetrieveRequest

Type:
  • Object
Source:

RetrieveResult

Type:
  • Object
Properties:
Name Type Description
fileProperties Array.<Metadata~FileProperties> Contains information about the properties of each component in the .zip file, and the manifest file package.xml
id String ID of the component being retrieved
messages Array.<Object> Contains information about the success or failure of the retrieve() call
zipFile String The zip file returned by the retrieve request. Base 64-encoded binary data
Source:

SaveResult

Type:
  • Object
Properties:
Name Type Description
success Boolean True if metadata is successfully saved
fullName String Full name of metadata object
Source:

UpdateMetadataInfo

Type:
  • Object
Properties:
Name Type Description
currentName String The API name of the component or field before the update
metadata Metadata~MetadataInfo Full specification of the component or field you wish to update
Source:

UpsertResult

Type:
  • Object
Properties:
Name Type Description
success Boolean True if metadata is successfully saved
fullName String Full name of metadata object
created Boolean True if metadata is newly created
Source: