See: Description
Interface | Description |
---|---|
ConfigurationContext |
Not Yet Available.
|
DocumentAction |
Executes a given document action; takes
DocumentActionContext as input. |
DocumentActionContext |
Contains contextual data about a document action during execution.
|
RecordAction |
Executes a given record action; takes
RecordActionContext as input. |
RecordActionContext |
Contains contextual data about a record action during execution.
|
Enum | Description |
---|---|
Usage |
Where in Vault the action is available for configuration and execution.
|
Annotation Type | Description |
---|---|
DocumentActionInfo |
Indicates a class is a document action.
|
RecordActionInfo |
Indicates a class is a record action.
|
A Record Action is a Java class that implements the RecordAction
interface and has the
RecordActionInfo
annotation. For example:
A class that implements the@RecordActionInfo(name="hello__c", label="Say Hello", object="hello_world__c")
public class Hello implements RecordAction { public boolean isExecutable(RecordActionContext context) { return true; } public void execute(RecordActionContext context) { // Get the current record on which the action is invoked List<Record> records = context.getRecords(); Record record= records.get(0); String name = record.getValue("name__v", ValueType.STRING); String[] originalName = null; if (!StringUtils.matches(name, "Hello(.*)")) { record.setValue("name__v","Hello, " + name); } else { originalName = StringUtils.split(name, ", "); record.setValue("name__v", originalName[1]); } // Save changes to the current record RecordService recordService = ServiceLocator.locate(RecordService.class); recordService.batchSaveRecords(VaultCollections.asList(record)).ignoreErrors().execute(); } }
RecordAction
interface must implement the following methods:
true
to make the action invokable.RecordService
or QueryService
) to change other records.RecordActionInfo
annotation has the following elements:
label
: Label of the actionobject
: If specified, the action is available for the specified object only.
If omitted, the action is available across all objects.usage
: If specified, the action is available for configuring in the specified usages only.
For example, USER_ACTION
. If omitted, the action is available across all supported usages.user_input_object_type
: If your action takes user input, identify the user input object type.user_input_object
: If your action takes user input, identify the user input object.
A Document Action is a Java class that implements the DocumentAction
interface and has the
DocumentActionInfo
annotation.
The following is an example of a document user action. We query for a field on all binders a document is referenced in, and then set those values in a field on the document.
A class that implements the@DocumentActionInfo(name = "get_partners__c", label="Find Partners", usages= Usage.USER_ACTION,lifecycle="general_lifecycle__c")
public class FindPartners implements DocumentAction { public void execute(DocumentActionContext documentActionContext) { DocumentVersion docVersion = documentActionContext.getDocumentVersions().get(0); //Get the binders this document version is referenced in String QueryBindersDocIsIn = "SELECT parent_binder_id__sys " + "FROM binder_node__sys WHERE content_id__sys = " + docVersion.getValue("id", ValueType.STRING); QueryService queryService = ServiceLocator.locate(QueryService.class); QueryResponse bindersDocIsIn = queryService.query(QueryBindersDocIsIn); Iterator<QueryResult> iterator = bindersDocIsIn.streamResults().iterator(); List<String> binderIds = VaultCollections.newList(); while (iterator.hasNext()) { QueryResult idResults = (QueryResult) iterator.next(); String parentBinderIds = idResults.getValue("parent_binder_id__sys", ValueType.STRING); binderIds.add(parentBinderIds); } //Get partner field values from the List of parent binders //Binder IDs must be in a comma separated String for In statement String QueryPartners = "SELECT partners__c " + "FROM documents WHERE id CONTAINS (" + String.join(",", binderIds) + ")"; QueryResponse binderPartnerValues = queryService.query(QueryPartners); Iterator<QueryResult> partnerIterator = binderPartnerValues.streamResults().iterator(); Set<String> partnerValues = VaultCollections.newSet(); while (partnerIterator.hasNext()) { QueryResult partnerResults = (QueryResult) partnerIterator.next(); partnerValues.addAll(partnerResults.getValue("partners__c", ValueType.REFERENCES)); } List<String> partnerValueList = VaultCollections.newList(); partnerValues.stream().forEach(partner -> partnerValueList.add(partner)); DocumentService docService = ServiceLocator.locate((DocumentService.class)); docVersion.setValue("partners__c", partnerValueList); docService.saveDocumentVersions(VaultCollections.asList(docVersion)); } public boolean isExecutable(DocumentActionContext documentActionContext) { return true; } }
DocumentAction
interface must implement the following methods:
true
to make the action invokable.DocumentService
or QueryService
) to change other documents.DocumentActionInfo
annotation has the following elements:
label
: Label of the actionlifecycle
: If specified, the action is available for the specified lifecycle only.
If omitted, the action is available across all document lifecycles.usage
: If specified, the action is available for configuring in the specified usages only.
For example, USER_ACTION
. If omitted, the action is available across all supported usages.user_input_object_type
: If your action takes user input, identify the user input object type.user_input_object
: If your action takes user input, identify the user input object.Copyright © Veeva Systems 2017–2019. All rights reserved.