on 08-10-2023 6:53 AM
Hi Everyone ,
I have a scenario where I need to fetch all the stored data using Select step and then based on that fetched XML message we need to check the Date segment . If that date segment time value is > current date - time +6 min then we need to select all the document Id for them .. But using my Groovy I am getting error cannot convert undefined or null to object .
Can some one help me with it
My inbound XML look like --
<?xml version='1.0' encoding='UTF-8'?><messages> <message id="1234575"> <AMC> <documentId>1234575</documentId> <details>1 - Litmos Dojo - WHITE BELT</details> <sign>Checked</sign> <date>2023-08-09T20:28:47</date> <product>XYAjhgpx0-M1</product> </AMC> </message> <message id="1234576"> <AMC> <documentId>1234576</documentId> <details>1 - Litmos Dojo - WHITE BELT</details> <sign>Checked</sign> <date>2023-08-09T20:28:47</date> <product>XYAjhgpx0-M1</product> </AMC> </message> <message id="1234577"> <AMC> <documentId>1234577</documentId> <details>1 - Litmos Dojo - WHITE BELT</details> <sign>Checked</sign> <date>2023-08-09T20:28:47</date> <product>XYAjhgpx0-M1</product> </AMC> </message></messages>
import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
import groovy.xml.XmlUtil;
import groovy.xml.StreamingMarkupBuilder;
import groovy.xml.*;
def currentDateTime = new Date()
def futureDateTime = currentDateTime + (6 * 60 * 1000) // Adding 6 minutes in milliseconds
def xmlRoot = new XmlSlurper().parseText(inboundXml)
xmlRoot.message.each { msg ->
def dateStr = msg.AMC.date.text()
def messageDateTime = Date.parse("yyyy-MM-dd'T'HH:mm:ss", dateStr)
if (messageDateTime > futureDateTime) {
def documentId = msg.AMC.documentId.text()
println("Document ID: $documentId")
}
}
Reagrds
Ritu
User | Count |
---|---|
74 | |
10 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.