Using the class “DocumentManager”
The dvelop_docs_dev.DocumentManager class provides a number of different functions for working with and managing documents from the connected document management system (DMS) using your custom Apex code.
Signature
global with sharing class DocumentManager extends SubscriberInterface
Superclass
Contents
Constructors
You can create an instance of DocumentManager with the following constructors:
DocumentManager()
This constructor creates a DocumentManager instance with default values.
Signature
global DocumentManager()
Methods
The class DocumentManager provides the following methods:
Note
For the superclass methods, take a look at Using the “SubscriberInterface” class.
downloadDocument(documentId)
This method downloads a DMS document with the transferred ID and returns the class DocumentDownloadResult with the name and content of the document file as the result.
Note
You can find a detailed guide to downloading documents here.
Signature
global DocumentDownloadResult downloadDocument(String documentId)
Parameters
documentId: The ID of the DMS document to be downloaded to Salesforce.
Data type: String
Returned entry
An instance of the class dvelop_docs_dev.DocumentDownloadResult containing the file name and the content of the document file.
downloadDocuments(documentIds, finisher, proceedOnFailure)
This method asynchronously downloads multiple DMS documents and passes the results to the transferred AsyncProcessFinisher job.
Note
You can find a detailed guide to downloading documents here.
Warning
This method starts an asynchronous queueable process with System.enqueueJob(). Note the limits for queueable jobs in the context in which you call the method.
Signature
global void downloadDocuments(List<String> documentIds, AsyncProcessFinisher finisher, Boolean proceedOnFailure)
Parameters
documentIds: A list of the IDs of the DMS documents to be downloaded to Salesforce.
Data type: List<String>
finisher: An instance of an AsyncProcessFinisher job. Once completed, this job is added to the Download queue and receives a list from the class DocumentDownloadResult as an output for its default parameter.
Data type: dvelop_docs_dev.AsyncProcessFinisher
proceedOnFailure: Defines whether the process is continued if an error occurs while downloading a document.
Data type: Boolean
Default value: false
Returned entry (to the “finisher” job)
A list with instances of the class dvelop_docs_dev.DocumentDownloadResult that contains the results of the individual downloads.
downloadDocumentToRecord(recordId, documentId)
This method downloads a DMS document with the transferred ID and saves the document as a file in a Salesforce record.
Note
You can find a detailed guide to downloading documents here.
Warning
This method executes DML. Note the limits for DML statements in the context in which you call the method. HTTP callouts are no longer possible directly after a DML operation.
Signature
global Id downloadDocumentToRecord(Id recordId, String documentId)
Parameters
recordId: The ID of the data record to which the downloaded DMS document is to be attached.
Data type: Id
documentId: The ID of the DMS document to be downloaded to Salesforce.
Data type: String
Returned entry
The ID of the ContentDocument record that was created for the downloaded DMS document on the related data record.
searchDocuments(options)
This method performs a search for documents in the DMS. The parameters of the search are defined by the transferred instance of DocumentSearchOptions.
Warning
The method searchDocuments(options) is obsolete but is still supported. However, we recommend switching to the new search(options) method to ensure that you can utilize all the benefits.
Signature
global List<Map<String, String>> searchDocuments(DocumentSearchOptions options)
Parameters
options: An instance of a choice of configured search options that are used as the basis for determining the parameters for the search.
Data type: dvelop_docs_dev.DocumentSearchOptions
Returned entry
A list of the documents found in generic dictionary format (Map).
search(options)
This method performs a search for documents in the DMS. The parameters of the search are defined by the transferred instance of DocumentSearchOptions.
Note
You can find a detailed guide to searching for DMS documents with complex search parameters here.
Signature
global List<Document> search(DocumentSearchOptions options)
Parameters
options: An instance of a choice of configured search options that are used as the basis for determining the parameters for the search.
Data type: dvelop_docs_dev.DocumentSearchOptions
Returned entry
A dvelop_docs_dev.Document list for the DMS documents found.
searchDocumentsWithIds(searchAttributeKey, documentIds)
This method performs a search for documents with specific IDs in the DMS.
Note
You can find a detailed guide to searching for DMS documents based on their IDs here.
Signature
global List<Document> searchDocumentsWithIds(String searchAttributeKey, List<String> documentIds)
Parameters
searchAttributeKey: The source property key that is assigned to the document ID in the connected DMS.
Data type: String
documentIds: The list of IDs for the searched documents.
Data type: List<String>
Returned entry
A dvelop_docs_dev.Document list for the DMS documents found.
getDocument(documentId)
This method retrieves a document with the specified ID from the DMS and provides the result as an instance of the Document class.
Note
You can find a detailed guide to retrieving a specific DMS document here.
Signature
global Document getDocument(String documentId)
Parameters
documentId: The ID of the DMS document whose properties, links and categories are identified.
Data type: String
Returned entry
An instance of the class dvelop_docs_dev.Document for the DMS document that was found using the ID on the connected DMS.
updateDocument(documentId, updatedCategory, updatedAttributes)
This method updates the properties and optionally the category of the DMS document with the given ID.
Note
You can find a detailed guide to updating a specific DMS document here.
Signature
global void updateDocument(String documentId, String updatedCategory, List<DocumentAttribute> updatedAttributes)
Parameters
documentId: The ID of the DMS document to be updated.
Data type: String
updatedCategory: The key of the new category. If the category is not to be updated, zero can be transferred instead.
Data type: String
updatedAttributes: A list of properties to be updated.
Data type: List<dvelop_docs_dev.DocumentAttribute>
deleteDocument(documentId, ?reason)
This method deletes a document or a folder with the given ID from the DMS.
Note
You can find a detailed guide to deleting a specific DMS item here.
Signature
global void deleteDocument(String documentId)
global void deleteDocument(String documentId, String reason)
Parameters
documentId: The ID of the DMS item to be deleted.
Data type: String
reason: The reason for deleting the item. The character string must be between three and 80 characters long.
Data type: String
Default value: “Deleted from d.velop documents for Salesforce.”
sendEmail(options)
This method sends an e-mail with attachments from Salesforce (ContentDocument) and the connected DMS (DMS documents). The details of the e-mail are defined by the transferred instance of DocumentEmailOptions.
Note
You can find a detailed guide to sending e-mails with Salesforce and DMS attachments here.
Signature
global void sendEmail(DocumentEmailOptions options)
Parameters
options: An instance of a choice of configured e-mail options that are used as the basis for determining the required e-mail details and attachments.
Data type: dvelop_docs_dev.DocumentEmailOptions
createFolder(category, attributes)
This method creates a folder with the specified category and the list of properties in the DMS.
Note
You can find a detailed guide to creating folders in the DMS here.
Signature
global String createFolder(String category, List<DocumentAttribute> attributes)
Parameters
category: The key of the category that the folder is to have.
Data type: String
attributes: A list of properties to be defined for the folder.
Data type: List<dvelop_docs_dev.DocumentAttribute>
Returned entry
The ID of the created folder in the DMS.
shareDocuments(downloadUrls)
This method creates temporary URLs for sharing DMS documents with third parties.
Note
You can find a detailed guide to sharing DMS documents with third parties here.
Warning
The method is unavailable in SharePoint environments.
Signature
global Map<String, String> shareDocuments(Set<String> downloadUrls)
Parameters
downloadUrls: A set of download URLs for the documents to be shared.
Data type: Set<string>
Returned entry
A generic dictionary (Map) with the transferred download URLs and the associated temporary links.