kevinn-veeva edited this page Nov 16, 2018 · 10 revisions

Triggers and Actions can be used to address a number of business requirements that cannot be configured in vault. This page describes some of the common use cases along with sample code that you can use with your vault to step through the code in the Vault Java SDK Debugger.


Introduction

The vsdk-object-sample project covers the creation of a vSDK Product record and related vSDK Country Brand records. The project will step through:

  • Field defaulting, field validation, and conditionally required fields on the vSDK Product record.
  • Creating related vSDK Country Brand records based on the vSDK Region associated with the vSDK Product record.
  • The creation of the vSDK Country Brand records will kick off a workflow on each country brand record.
  • The completion of the workflow will trigger a state change (update) to the vSDK Country Brand record and it's associated vSDK Product record.
  • A custom User Action to change the owner role of a vSDK Product's related vSDK Country Brand records.

General Guidelines

  • The RequestContextObject class implements Request Context functionality for storing a reusable map of regions to countries.
  • The UserDefinedUtils class implements User-Defined Class functionality for throwing batch errors - throwBatchErrors - and conditionally requiring fields - requiredDependentField.
  • The UserDefinedUtils class also contains an example_type variable that can be set to control functionality in the project. You can set this variable to any of the following. By default, it is set to ALL:
    • ALL - this will run through all the triggers and initiate workflows and user actions in CountryBrandLifeCycleUserActions.java
    • NO_WORKFLOW - this will run all triggers but will not run workflows or state changes in CountryBrandLifeCycleUserActions.java.
    • REQUEST_CONTEXT - this will run through triggers demonstrating RequestContext functionality in ProductInitializeRequestContextValue.java and ProductCreateRelatedCountryBrand.java
  • The workflows are evaluated on the vSDK Country Brand records.

Setup

The project contains two separate vault packages (VPK) in the deploy-vpk directory with the necessary Objects, Actions, Lifecycles, Workflows, and custom object actions for the following examples.

The VPKs need to be deployed to your vault prior to debugging these use cases:

  1. Clone or download the sample Maven project vSDK Object Sample project from GitHub.
  2. Run through the Getting Started guide to set up your deployment environment.
  3. Log in to your vault and navigate to Admin > Deployment > Inbound Packages and click Import:

    Deploy Object Action code: Select the \deploy-vpk\code\vsdk-object-sample-action-code.vpk file.

  4. From the Actions menu, select Review & Deploy. Vault displays a list of all components in the package.
    reviewdeploy-code
  5. Click Next.
  6. On the confirmation page, review and click Finish. You will receive an email when Vault completes the deployment.
  7. Repeat steps 3-6 for the vault components:

    Deploy vault components: Select the \deploy-vpk\vsdk-object-sample-components\vsdk-object-sample-components.vpk file.

Once the package has been deployed, you will want to review the configuration and understand the normal behavior so you can observe the effects of the sample trigger code.

Below is a rundown of the included components.

Objects
  • vSDK Country (vsdk_country__c)
  • vSDK Country Brand (vsdk_country_brand__c)
  • vSDK Product (vsdk_product__c)
  • vSDK Region (vsdk_region__c)

Object Actions

All States:

  • Run vSDK Change Owner User Action (vSDKChangeOwnerUserAction.java)
Lifecycles

lifecycle

Workflows

workflows


Run the Project

To see the project in action, configure the debugger and set breakpoints or deploy the code to your vault.

Once the project is in debug or deployed to vault:

  1. Navigate to your Admin -> Business Admin -> vSDK Product tab in your vault and Create a new record:
    createrecord
  2. Enter any value in the Name field and select a Region.
  3. Click Save.
  4. While vault attempts to save the record, each of the trigger examples discussed in this wiki will execute in order.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.