Package com.veeva.vault.sdk.api.document
package com.veeva.vault.sdk.api.document
This package provides interfaces to manage documents and binders. The interfaces in this package allow you to:
- Update fields on the latest version of a document
- Create and delete documents
- Create and delete document versions
- Add attachments and renditions
Updating and Deleting Documents
UseDocumentService
to create a DocumentVersion
object, which is an instance of an existing document. You can then update field values or delete the document.
After updating or deleting a DocumentVersion
, you need to execute a batch operation to commit the operation. For
example, after updating a document, you need to execute DocumentService.saveDocumentVersions(java.util.List)
(java.util.List)}
to save your changes.
In the following example, we update fields on the existing document ID 320, delete document ID 310, and delete a specific version of document ID 330.
DocumentService documentService = ServiceLocator.locate(DocumentService.class);
DocumentVersion documentVersion = documentService.newDocumentWithId("320");
LocalDateTime ldt = LocalDateTime.of(2016, Month.AUGUST, 22, 14, 30);
documentVersion.setValue("expiration_date__vs", LocalDate.now());
List languageList = VaultCollections.newList();
languageList.add("en_US");
documentVersion.setValue("language__v", languageList);
documentVersion.setValue("approved__c", Boolean.FALSE);
documentVersion.setValue("datetime__c", ldt.atZone(ZoneId.of("Asia/Kuala_Lumpur")));
DocumentVersion documentVersion2 = documentService.newDocumentWithId("310");
DocumentVersion documentVersion3 = documentService.newDocumentVersion("330_0_1");
List versionsToUpdate = VaultCollections.newList();
versionsToUpdate.add(documentVersion);
List versionsToDelete = VaultCollections.newList();
versionsToDelete.add(documentVersion2);
versionsToDelete.add(documentVersion3);
documentService.deleteDocumentVersions(versionsToDelete);
documentService.saveDocumentVersions(versionsToUpdate);
Creating Documents, Renditions, and Versions
The following example usesConnectionService
,
DocumentService
, and FileReference
to set the source file, get new version information, and create a new attachment and rendition.
@DocumentActionInfo(label = "testCode")
public class DeepCopyDocument implements DocumentAction {
@Override
public boolean isExecutable(DocumentActionContext documentActionContext) { return true; }
@Override
public void execute(DocumentActionContext documentActionContext) {
ConnectionService connectionService = ServiceLocator.locate(ConnectionService.class);
ConnectionContext connectionContext = connectionService.newConnectionContext("connectionApiName", ConnectionUser.CONNECTION_AUTHORIZED_USER);
DocumentService documentService = ServiceLocator.locate(DocumentService.class);
DocumentSourceFileReference documentSourceFileReference = documentService.newDocumentSourceFileReference(connectionContext, "1_0_1");
DocumentVersion documentVersion = documentService.newDocument();
documentVersion.setValue("type__v", VaultCollections.asList("Claims"));
documentVersion.setValue("subtype__v", VaultCollections.asList("Core Message Map"));
documentVersion.setValue("lifecycle__v", VaultCollections.asList("Claims"));
documentVersion.setValue("name__v", "file name");
documentVersion.setSourceFile(documentSourceFileReference);
documentVersion.suppressRendition();
SaveDocumentVersionsResponse response = documentService.createDocuments(VaultCollections.asList(documentVersion));
String newDocVersionId = response.getSuccesses().get(0).getDocumentVersionId();
//Get new version info
String[] parts = StringUtils.split(newDocVersionId, "_");
String docId = parts[0];
Integer major = Integer.valueOf(parts[1]);
Integer newMinor = Integer.valueOf(parts[2]) + 1;
DocumentSourceFileReference secondVersionSourceFileReference = documentService.newDocumentSourceFileReference(connectionContext, "1_0_2");
DocumentVersion newVersion = documentService.newVersion(docId);
newVersion.setValue("type__v", VaultCollections.asList("Claims"));
newVersion.setValue("subtype__v", VaultCollections.asList("Core Message Map"));
newVersion.setValue("lifecycle__v", VaultCollections.asList("Claims"));
newVersion.setValue("status__v", VaultCollections.asList("Draft"));
newVersion.setValue("name__v", "1-17-2 v2");
newVersion.setValue("major_version_number__v", BigDecimal.valueOf(major));
newVersion.setValue("minor_version_number__v", BigDecimal.valueOf(newMinor));
newVersion.setSourceFile(secondVersionSourceFileReference);
documentService.migrateDocumentVersions(VaultCollections.asList(newVersion));
//create attachment
DocumentAttachmentFileReference documentAttachmentFileReference = documentService.newDocumentAttachmentFileReference(connectionContext, "1");
DocumentAttachment documentAttachment = documentService.newDocumentAttachment(documentAttachmentFileReference, docId);
documentService.createAttachments(VaultCollections.asList(documentAttachment));
//create rendition
DocumentRenditionFileReference documentRenditionFileReference = documentService.newDocumentRenditionFileReference(connectionContext, "1_0_1", "viewable_rendition__v");
DocumentRendition rendition = documentService.newDocumentRendition(documentRenditionFileReference, "1_0_1", "viewable_rendition__v");
documentService.createRenditions(VaultCollections.asList(rendition));
}
}
-
ClassDescriptionResponse from a call to
DocumentService.deleteDocumentVersions(List)
(List)}.Represents the target attachment.Represents an attachment file from the current or from another Vault.Provides methods to retrieve common metadata on Boolean fields.Provides methods to retrieve common metadata on component fields.Provides methods to retrieve common metadata on date fields.Provides methods to retrieve common metadata on DateTime fields.Deprecated.Deprecated.as of 25R1.3, seeDocumentMetadataService.newDocumentFieldMetadataRequestBuilder()
Creates an instance ofDocumentFieldCollectionRequest
.Deprecated.Deprecated.as of 25R1.3, seeDocumentMetadataService.newDocumentFieldMetadataRequestBuilder()
Creates an instance ofDocumentFieldFilter
.Provides methods to retrieve common metadata on the specified document field.Retrieves a List of all fields in theDocumentFieldMetadata
collection once a request is built for the given document type.Creates an instance ofDocumentFieldMetadataRequest
.Holds anDocumentFieldMetadata
collection.A list of the possible document field types.A list of all of the possible field types that a document field can be.Represents a document file from the current or from another Vault.Provides methods to retrieve common metadata on Boolean formula fields.Provides methods to retrieve common metadata on Date formula fields.Provides methods to retrieve common metadata on DateTime formula fields.A container for a formula field expression.Provides methods to retrieve common metadata on formula fields.A list of all possible missing field behavior types for a formula field.A list of all possible return types for a formula field.This is a representation of a typed formula field.Provides methods to retrieve common metadata on number formula fields.Provides methods to retrieve common metadata on text formula fields.Provides methods to retrieve common metadata on ID fields.Provides methods to retrieve common metadata on lookup fields.A list of all possible field types for a lookup field.This is a representation of a typed lookup field.Provides methods to retrieve common metadata on object reference lookup fields.Provides methods to retrieve common metadata on picklist lookup fields.Provides methods to retrieve document type and document field metadata.Provides methods to retrieve common metadata on number fields.Provides methods to retrieve common metadata on object reference fields.Provides methods to retrieve common metadata on picklist fields.A container for a document relationship criteria expression.Represents the target document-version rendition.Represents a document-version rendition file from the current or from another Vault.Provides methods to update and delete documents.Represents a document-version source file from the current or from another Vault.Provides methods to retrieve common metadata on text fields.Provides methods to retrieve common metadata information of the specified document type.A list of all possible levels aDocumentType
can be.Retrieves an instance ofDocumentType
to build the request for retrieving document type metadata.Creates an instance ofDocumentTypeRequest
.Provides methods to retrieve common metadata on URL fields.Represents a document version.Represents a successful result of processing a document in a batch operation, such as a save or delete.Response from a call toDocumentService.saveDocumentVersions(List)
.
DocumentMetadataService.getField(String)