Sign In   Register

This article outlines how to properly update a transaction’s status via a scheduled job when a form uses the Submission Completed Processor Service, and provides guidance on using REST API calls to resolve the following error:

error

Error : Servlet request not available - could not invoke submission completed processor against submission.

Applicable To

  • Product: Journey Manager
  • Versions: All versions

Prerequisites

  1. While building the maestro form, ensure that the 'Use server side transact functions' checkbox is disabled. 
  2. You must have the necessary access for Journey Manager and Maestro to:
    • Create services
    • Configure scheduled jobs
    • Edit Maestro forms

Use Case

The Submission Completed Processor Service does not support manual transaction status updates within a scheduled job, since no servlet request context is available. 
Using TxnUpdater in a scheduled job bypasses the Submission Completed Processor and causes errors. 

note

When a call is made from the Groovy console, a request is sent to Journey Manager. Since the Submission Completed Processor Service is designed to run only when a request is present, it is automatically invoked when the transaction status is updated through the groovy console.

Steps to recreate

1- Build a maestro form without enabling 'Use server side Transact Functions' checkbox and deploy it to JM.

 
2- Go to Form > Form version > Submission completed processor > Click on New or select any existing service from the dropdown.

 
3- And attach the newly created service. 

 
4- Create a new Scheduled service that updates the status of saved transactions to completed using TxnUpdater(), for example:

import com.avoka.core.groovy.GroovyLogger as logger;

import com.avoka.tm.func.*;

import com.avoka.tm.http.*

import com.avoka.tm.job.*

import com.avoka.tm.query.*;

import com.avoka.tm.security.*;

import com.avoka.tm.svc.*;

import com.avoka.tm.test.*;

import com.avoka.tm.util.*

import com.avoka.tm.vo.*;

String txnCode = ‘ABCD’; // REPLACE WITH A REAL TXN TRACKING CODE

Txn txn = new TxnQuery().setTrackingCode(txnCode).firstValue();

new TxnUpdater(txn)

.setFormStatus(Txn.FORM_SAVED)

.setDeliveryStatus(Txn.DELIVERY_NOT_READY)

.setReceiptStatusReady()

.update();

txn = new TxnQuery().setTrackingCode(txnCode).firstValue();

new TxnUpdater(txn)

.setAttachmentsStatus(Txn.FORM_COMPLETED)

.setFormStatus(Txn.FORM_COMPLETED)

.update();

5- Configure a scheduled job in System > Scheduled Jobs > New Scheduled Service Job, and attach the above service.

 
6- Render the form, save it, and then run the ‘Client scheduled job’.
7-We observe that the transaction status changes to “Completed”, but in the transaction event log we see the following error –

error

Error : Servlet request not available - could not invoke submission completed processor against submission.

Resolution

1- Avoid directly updating submission statuses via TxnUpdater() in scheduled jobs. Instead, invoke a REST API call to change the transaction status. This ensures the Submission Completed Processor runs as expected.
2- Create a dedicated REST user account with all required roles and permissions. Please refer to:

3- It’s recommended to configure a service connection for the REST API and call the REST username/password in your scheduled job. 

 
For more details, see:

4- Example code using REST APIs, Service connection: 

String txnCode = 'M9ZBJDJ'; // REPLACE WITH A REAL TXN TRACKING CODE

Txn txn = new TxnQuery().setTrackingCode(txnCode).firstValue();

  String invoke(SvcDef svcDef)

    {

      List<Txn> txnList = new TxnQuery()

      .setFormStatus("Saved")

      .withPropertyMap()

      .listValues()

logger.info("Found transactions to be completed")

String message =

    """{

    "setId" : "${txn.id}",

    "setFormStatus" : "Completed" //Transaction status changed from Saved to Completed

  }""" 

SvcConn svcConn = new SvcConnQuery()

     .setName("Client Service Connection") //consists of username and password

     .setClientCode("ammu")

     .firstValue();

HttpResponse response = new PostRequest(svcConn.endpoint)

       .setMessage(message)

       .setBasicAuth(svcConn.username, svcConn.password)

       .setContentType("application/json")

       .execute()

logger.info("form completed")

            }

References