• Platform
    • Manager
    • Maestro
    • Exchange
    • Workspaces
    • Analytics
    • Springboard
    • API
Transact Services Guide (TSG)

Transact Services Guide (TSG)

  • Getting Started
  • Groovy Guide
  • Service Development
  • Groovy Services API
  • REST API

›Groovy Services API

Getting Started

  • Introduction

Groovy Guide

  • Groovy Guide
  • Groovy Declarations
  • Control Statements

Service Development

  • Service Development
  • Transaction Processing Sequence
  • Service Logging
  • Remote Service Calls
  • Fluent Security Configuration
  • Third-party Libraries

Groovy Services API

  • Groovy Services API
  • Fluent Function
  • Delivery Function
  • Form Version Selector
  • Form Security Filter
  • Form Prefill
  • Tracking Number
  • Form Dynamic Data
  • Submission Preprocessor
  • Receipt Number
  • Form Saved Processor
  • Submission Data Validator
  • Submission Completed Processor
  • Render Receipt Service
  • Delivery Process
  • Task Expiry Process
  • Email Service
  • Job Action
  • Scheduled Service
  • Groovy Service
  • SSO Revalidation
  • SSO Get Authentication Token
  • SSO Authentication OK Response
  • SSO Authentication Provider
  • Transaction History Publisher
  • Virus Scan

REST API

  • REST API
  • REST Application Package API
  • REST Delivery API
  • REST Form Groups API
  • REST Groovy Service Invoke v2
  • REST Service Definitions API
  • REST Tasks API
  • REST TestCenter API
  • REST TPac API
  • REST Transactions API
  • REST Transaction History API

Workspaces API

  • Workspaces API
  • Filters
  • Sort
  • Workspaces Category API
  • Workspaces Current User API
  • Workspaces Extract Name API
  • Workspaces Form API
  • Workspaces Group API
  • Workspaces Job API
  • Workspaces Org API
  • Workspaces Property Name API
  • Workspaces Space API
  • Workspaces Txn API
  • Workspaces User API

Form Dynamic Data

The Form Dynamic Data service is used provide forms with dynamic data in real-time while the user is interacting with the form.

Service Invoke Parameters

Parameter Description Nullable
svcDef the service definition value object, see SvcDef no
txn the transaction record value object, see Txn yes
request the servlet HttpServletRequest no
user the authenticated user, see User yes

Script Result

The script should return a JSON string value to be bound into the HTML form's data model.

Error Handling

If your Groovy script throws an error the FormDynamicDataServlet will return a HTTP 500 error code back to the form. It is up to the form to handle the error returned. The system will also log the error to the Journey Manager database event log specifying an event type of 'Error'.

Service Template

This section shows service template Groovy script.

import com.avoka.core.groovy.GroovyLogger as logger
import com.avoka.tm.vo.*
import javax.servlet.http.*

class FluentDynamicData {

    /*
     * Perform Form Dynamic Data service call.
     *
     * returns: REST response text data
     */
    String invoke(SvcDef svcDef, Txn txn, HttpServletRequest request, User user) {

        // TODO: replace with data lookup call
        
        String data = '''{
          "address": {
            "firstLine": "123 Wall Street"
          }
        }'''

        return data
    }
}

Unit Test Template

This section shows unit test template Groovy script.

import com.avoka.core.groovy.GroovyLogger as logger
import com.avoka.tm.svc.*
import com.avoka.tm.test.*
import com.avoka.tm.util.*
import com.avoka.tm.vo.*
import org.junit.Test

class UnitTest extends AbstractJUnitTest {

    /*
     * Perform service unit test
     *
     * throws: exception if unit test fails
     */
    @Test
    void testAddressFirstLine() throws Exception {

        Txn txn = new MockVoBuilder().createTxnOpened()
        MockRequest request = new MockRequest()

        Map params = [
            "svcDef": svcDef,
            "txn": txn,
            "request": request,
            "user": null
        ]

        String result = (String) new ServiceInvoker(svcDef).invoke(params)

        logger.info result

        Path path = new Path(result)

        assert "123 Wall Street" == path.val("address.firstLine")
    }
}
← Tracking NumberSubmission Preprocessor →

Terms & Conditions

Privacy Policy

Cookie Policy

Copyright © 2003-2022 Temenos Headquarters SA