Need to update the value or increment the value in sequence field in below code snippet as follows :
// Loop through each of the incoming task and add them to the new request
whTasks.eachWithIndex { task, idx ->
// idx = idx + 1
oWHTaskNode.@ws_no = task[1].ws_no
log.info (" IC : Incoming WT - " + oWHTaskNode.@ws_no)
oWHTaskNode.@itemno = task[1].itemno
log.info (" IC : Incoming Item - " + oWHTaskNode.@itemno)
)
oWHTaskNode.@lot_number = task[1].lot_number
log.info (" CT WT : LNO = " + oWHTaskNode.@lot_number)
oWHTaskNode.@itemno = task[1].itemno
log.info (" CT WT : INO = " + oWHTaskNode.@itemno)
oWHTaskNode.@sequence = "1"
log.info (" CT WT : SEQ = " + oWHTaskNode.@sequence)
//Since we already have one WHTask node in the Default request, we replace it with the first WHTask from incoming request
// Later, other WHTasks will be added in the default request
if(idx == 0){
// First task, therefore replace the WHTask in Default (New) request with this
//oRequestNew.Body.WarehouseOrderConfirmation.WHOrder.WHTask.replaceNode{ oWHTaskNode }
//Direct replacement of node is not working, so removing the node by replacing with EMPTY and then adding a new node ;-)
oRequestNew.Body.InductionConfirmation.CO.FP.WS.replaceNode{}
oRequestNew.Body.InductionConfirmation.CO.FP.appendNode( oWHTaskNode )
}else {
// Subsequent WHTasks will be added as a new node in the Default (New) request
oRequestNew.Body.InductionConfirmation.CO.FP.appendNode( oWHTaskNode )
}
oWHTaskNode = new XmlSlurper().parseText(whTaskNodeStr)
}