See: Description
Interface | Description |
---|---|
ConfigurationContext |
Representation of the configuration details for an action, such as the usage context in which the action is configured
and executed against, and parameter values set by an Administrator in the object configuration for the action.
|
DocumentAction |
Executes a given document action; takes
DocumentActionContext as input. |
DocumentActionContext |
Contains contextual data about a document action during execution.
|
PostExecutionDocumentActionUIContext |
Set UI components during the post-execution phase for a document action
in the
USER_ACTION use case. |
PostExecutionRecordActionUIContext |
Set UI components during the post-execution phase for a record action
in the
USER_ACTION use case. |
PostExecutionUIContext |
Set UI components during the post-execution phase for a record
or document action in the
USER_ACTION use case. |
PostExecutionUserActionUIBehavior |
Contains additional UI data to be utilized for a record or document action
during the post-execution phase in the
USER_ACTION use case. |
PostExecutionUserActionUIBehavior.Builder |
Build a
PostExecutionUserActionUIBehavior with UI data to be set in the action's
onPostExecute method. |
PreExecutionDocumentActionUIContext |
Set UI components during the pre-execution phase for a document
action in the
USER_ACTION use case. |
PreExecutionRecordActionUIContext |
Set UI components during the pre-execution phase for a record
action in the
USER_ACTION use case. |
PreExecutionUIContext |
Set UI components during the pre-execution phase for a record
or document action in the
USER_ACTION use case. |
PreExecutionUserActionUIBehavior |
Contains additional UI data to be utilized for a record or document action
during the pre-execution phase in the
USER_ACTION use case. |
PreExecutionUserActionUIBehavior.Builder |
Build a
PreExecutionUserActionUIBehavior with UI data to be set in the action's
onPreExecute method. |
RecordAction |
Executes a given record action; takes
RecordActionContext as input. |
RecordActionContext |
Contains contextual data about a record action during execution.
|
UserActionExecutionBanner |
Represents a post-execution banner for a record or document action
in the
USER_ACTION use case. |
UserActionExecutionBanner.Builder |
Build a
UserActionExecutionBanner to be set on a PostExecutionUserActionUIBehavior
during the action's onPostExecute method. |
UserActionExecutionDialog |
Represents a pre-execution dialog for a record or document action in the
USER_ACTION use case. |
UserActionExecutionDialog.Builder |
Build a
UserActionExecutionDialog to be set on a PreExecutionUserActionUIBehavior
during the action's onPreExecute method. |
UserActionUIService |
Provides builders for working pre- and post-execution UI behavior actions
in the
USER_ACTION use case. |
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", usages={Usage.USER_ACTION, Usage.WORKFLOW_STEP})
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(); } public void onPreExecute(PreExecutionRecordActionUIContext context) { // Get the UserActionUIService UserActionUIService userActionUIService = ServiceLocator.locate(UserActionUIService.class); // Build a UserActionExecutionBanner with a message String dialogMessage = "Sample dialog message"; String dialogTitle = "Sample dialog title"; UserActionExecutionDialog dialog = userActionUIService.newUserActionExecutionDialogBuilder() .withMessage(dialogMessage) .withTitle(dialogTitle) .build(); // Build a PreExecutionUserActionUIBehavior with the banner PreExecutionUserActionUIBehavior preExecBehavior = userActionUIService.newPreExecutionUserActionUIBehaviorBuilder() .withDialog(dialog) .build(); // Set the pre-execution user action UI behavior on the context context.setUserActionUIBehavior(preExecBehavior); } public void onPostExecute(PostExecutionRecordActionUIContext context) { // Get the UserActionUIService UserActionUIService userActionUIService = ServiceLocator.locate(UserActionUIService.class); // Build a UserActionExecutionBanner with a message String bannerMessage = "This is a sample banner message"; UserActionExecutionBanner banner = userActionUIService.newUserActionExecutionBannerBuilder() .withMessage(bannerMessage) .build(); // Build a PostExecutionUserActionUIBehavior with the banner PostExecutionUserActionUIBehavior postExecBehavior = userActionUIService.newPostExecutionUserActionUIBehaviorBuilder() .withBanner(banner) .build(); // Set the post-execution user action UI behavior on the context context.setUserActionUIBehavior(postExecBehavior); } }
RecordAction
interface must implement the following methods:
true
to make the action invokable.RecordService
or QueryService
) to change other records.RecordAction
interface may also implement the following methods:
USER_ACTION
use case. As illustrated in the example above,
a pre-execution dialog can be configured here, with a custom title and message.USER_ACTION
use case. As illustrated in the example above,
a post-execution banner can be configured here, with a custom message.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; } public void onPreExecute(PreExecutionDocumentActionUIContext context) { // Get the UserActionUIService UserActionUIService userActionUIService = ServiceLocator.locate(UserActionUIService.class); // Build a UserActionExecutionBanner with a message String dialogMessage = "Sample dialog message"; String dialogTitle = "Sample dialog title"; UserActionExecutionDialog dialog = userActionUIService.newUserActionExecutionDialogBuilder() .withMessage(dialogMessage) .withTitle(dialogTitle) .build(); // Build a PreExecutionUserActionUIBehavior with the banner PreExecutionUserActionUIBehavior preExecBehavior = userActionUIService.newPreExecutionUserActionUIBehaviorBuilder() .withDialog(dialog) .build(); // Set the pre-execution user action UI behavior on the context context.setUserActionUIBehavior(preExecBehavior); } public void onPostExecute(PostExecutionDocumentActionUIContext context) { // Get the UserActionUIService UserActionUIService userActionUIService = ServiceLocator.locate(UserActionUIService.class); // Build a UserActionExecutionBanner with a message String bannerMessage = "This is a sample banner message"; UserActionExecutionBanner banner = userActionUIService.newUserActionExecutionBannerBuilder() .withMessage(bannerMessage) .build(); // Build a PostExecutionUserActionUIBehavior with the banner PostExecutionUserActionUIBehavior postExecBehavior = userActionUIService.newPostExecutionUserActionUIBehaviorBuilder() .withBanner(banner) .build(); // Set the post-execution user action UI behavior on the context context.setUserActionUIBehavior(postExecBehavior); } }
DocumentAction
interface must implement the following methods:
true
to make the action invokable.DocumentService
or QueryService
) to change other documents.DocumentAction
interface may also implement the following methods:
USER_ACTION
use case. As illustrated in the example above,
a pre-execution dialog can be configured here, with a custom title and message.USER_ACTION
use case. As illustrated in the example above,
a post-execution banner can be configured here, with a custom message.@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–2021. All rights reserved.