Skip to main content

Version: 23.10

Form Saved Processor

The Form Saved Processor is called immediately after the user has saved a form to Journey Manager.

Service Invoke Parameters

Parameters are not nullable except where otherwise indicated.

ParameterDescription
svcDefSvcDef
A service definition value object.
txnTxn
A transaction record value object.
requestHttpServletRequest
Nullable. A HTTP servlet request.
userUser
Nullable. An authenticated user.

Error Handling

If an error occurs, the system catches the error and logs it to the Journey Manager database error log. The user should not be aware that any error has occurred.

info

Any changes made by the service to the database are persisted with the transaction. It is up to the service to undo any changes it has made.

Templates

Service

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

class FluentFormSavedProcessor {

/**
* Perform form save processor service
*/
void invoke(SvcDef svcDef, Txn txn, HttpServletRequest request, User user) {

// TODO: perform business logic

new TxnUpdater(txn)
.setProperty("IDV-Status", "Pending")
.update()
}
}

Unit Test

import com.avoka.core.groovy.GroovyLogger as logger
import com.avoka.tm.query.*
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 testIDVStatusUpdate() throws Exception {

String xmlData = testParams['Test XML Data']
Txn txn = new MockVoBuilder().createTxnSavedWithXml(xmlData)
MockRequest request = new MockRequest()

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

new ServiceInvoker(svcDef).invoke(params)

txn = new TxnQuery()
.setTxn(txn)
.withPropertyMap()
.firstValue()

logger.info txn

assert txn.formStatus == Txn.FORM_SAVED

assert txn.propertyMap["IDV-Status"] == 'Pending'
}
}