2
1
0

My loan application form has a feature that allows the customer to recalculate the parameters for a loan after the form has been submitted. In TM I want a new task to be created, and be processed by my Delivery Process, each time the customer hits 'Recalculate'. I'm trying to do it in a Fluent Dynamic Data service like this:

Txn full = new TxnQuery()
      .setTrackingCode(txn.trackingCode)
      .withFormXml()
      .firstValue()

// update XML with new values
XmlDoc xmlDoc = new XmlDoc(full.formXml)
// ....

// remove sys info
xmlDoc.removeNodes("/AvokaSmartForm/SFMData/SystemProfile/SubmissionNumber")
xmlDoc.removeNodes("/AvokaSmartForm/SFMData/SystemProfile/ReceiptNumber")
xmlDoc.removeNodes("/AvokaSmartForm/SFMData/SystemProfile/SubmitDateString")
xmlDoc.removeNodes("/AvokaSmartForm/SFMData/SystemProfile/RequestLogKey")

TxnBuilder txnBuilder = new TxnBuilder()
        .setFormDataXml(xmlDoc.toString())
        .setFormCode(full.formCode)
        .setSpaceName(full.spaceName)
        .setTaskType('Form')
        .setTaskSubject('Change')

if (user) {
    txnBuilder.setLoginName(user.loginName)

} else {
    txnBuilder.setContactEmailAddress(contactEmail)

}

Txn newTxn = txnBuilder.build()

new TxnUpdater(newTxn)
    .setFormStatus("Completed")
    .update()


def json = JsonOutput.toJson([
        trackingCode: newTxn.trackingCode,
        // more json
])

return json.toString()

 

But t doesn't work. The task is created, but my status is ignored; task status is 'Task Form Assigned'.

What do I have to set in the builders to get the task completed?

    CommentAdd your comment...

    3 answers

    1.  
      4
      3
      2

      Hi Andy,

      I have reviewed the TxnUpdater and it does not perform this state transition.

      However for what you are trying to do you should be using class below which is designed for this purpose.

      DeliveryTxnBuilder

      regards Malcolm

       

       

        CommentAdd your comment...
      1.  
        1
        0
        -1

        Hi Andy,

        In the Fluent API all the value object classes are immutable, once they are created they never change.  So after you perform the update you need to reload the newTxn object to see the changes.

        Please see:  TxnQuery

        regards Malcolm

          CommentAdd your comment...
        1.  
          1
          0
          -1

          Hi Andy,

          looking at your code the TxnBuilder is not returning a newTxn value which is passed to TxnUpdater.  Please see the Javadoc on how to use this class:

          TxnBuilder

          regards Malcolm

          1. Andy Geach

            Sorry Mal, I tried to simplify the code for the question. I've updated the question with the real code.

          CommentAdd your comment...