I found the answer using chatgpt.
On the message:
<HumanResource>
<AssignmentId>
<IdValue name="recordid">a0j6N000002HDkmQAG</IdValue>
<IdValue name="externalid">8324137</IdValue>
<IdValue name="customid">JOB182741</IdValue>
</AssignmentId>
</HumanResource>
The script:
import groovy.util.XmlSlurper
import com.sap.gateway.ip.core.customdev.util.Message
def Message processData(Message message) {
def xml = message.getBody(String.class)
def completeXml = new XmlSlurper().parseText(xml)
def NTV_JOBID = completeXml.AssignmentId.IdValue.find { it.@name == 'customid' }.text()
message.setProperty("NTV_JOBID", NTV_JOBID)
return message
}
Produces the exhange property NTV_JOBID with value JOB182741
Few things that i noticed
1) originally i did not do import of groovy.util.XmlSlurper
2) in walking down the tree you must NOT start at the root (HumanResource), but 1 down (AssignmentId)
3) the part between {} is quite different than i thought it would be. My guess was more like an x-path query as it would look when you set an exchange property directly in CPI. I'm still not sure what it. stands for, but it works.
Bit of a frustrating search but finding it in the end still makes me happy.
Kr
Robert
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.