Precisely Enterworks

 View Only

Using Velocity Language (VTL) to Generate a random UUID for a record

  • 1.  Using Velocity Language (VTL) to Generate a random UUID for a record

    Posted 02-13-2023 07:40

    Hello All,

    Ran into an interesting use case a few months back for a customer that was worth sharing for future implementations.

    Use Case: Customer wanted to have an additional random ID generated for a new record in addition to the Sequenced Attribute as an ID.  EnterWorks only allows one sequenced attribute per repository, so this was a business challenge we needed to overcome.  

    This use case was created to allow a secondary identifier to be generated for a record in a repository that is not marked as Seq Gen Ind = Yes.  Traditionally, only one sequenced attribute can be created per repository. 

     

    VTL Layout- 

    #set( $str="")## 

    #set( $uuid=$str.getClass().forName("java.util.UUID"))## 

    $uuid.randomUUID().toString() 

      

    Note: This option only works as a Vtl-Like rule or in a Syndication Template.  It will not work with the standard Pre-Save Callout 

    Here is an example from a Syndication Template:

    Edit Syndication Template Mapping 
Display Name 
Required Indicator 
Builder 
Preview 
Rendered Text: 
6fa3118e-7280-4f7a-aef7-26bab736299d 
Attribute Formula: 
tOString() 
Fill In Values For the Attributes: 
Found Attribute Name 
p rev i 
Value



    ------------------------------
    Eric Gilboe
    Practice Director - EnterWorks
    eric.gilboe@goamplifi.com
    Atlanta | Chicago | Dallas | Los Angeles | London
    ------------------------------