Skip to Content

Fieldglass and CPI - Groovy concatenate ID and description in incoming description tag

Hello, we are integrating Fieldglass and we have a limitation in Line Items extrinsic custom fields, we need to send the MaterialID to the ERP, Fieldglass can send the values in the XML but the mapping tool designed for the CPI iflow doesnt have an option to map this field(so the value is lost) so we are trying to map this through Groovy script.

<urn:ExternalReqForApprovalImportRequest xmlns:urn="urn:Ariba:Buyer:vrealm_1" xmlns:soapenv="" xmlns:xs="" partition="" variant="">
			<urn:Name>Servicios de limpieza</urn:Name>
					<urn:ItemDescription>TEST DESCRIPTION</urn:ItemDescription>
							<Extrinsic name="InternalID">7000083</Extrinsic>
							<Extrinsic name="MaterialGroup">MAC_00</Extrinsic>

The idea is to store the LineNumber and the InternalID, so the Message Mapping executes and then after, we do the additional assignment for this value.

Our problem is that in the Groovy script i cannot map the Extrinsic field required, i tried several tests but looks like we dont have the right logic to map correctly the extrinsic value (we can actually map correctly the LineNumber)

We did a simple iflow with the payload as Body from Content mapping and tried this groovy:

import java.util.HashMap;
def Message processData(Message message) {      
            def body = message.getBody(;
            HashMap<Integer, String> hmap = new HashMap<Integer, String>();
            def Root = new XmlSlurper().parse(body);
        hmap.put(it.ExternalLineNumber.text().toString(), it.LineExtrinsics.Extrinsics.Extrinsic.@'InternalID'.text().toString());
        catch(Exception ex){
            //put relevant exception handling here
            message.setProperty("hashmapdata", hmap);
            return message;

What we are trying for now is just store a Property to check that our code is running correctly, the mapping for ItemDescription is correct, but the one for the deeper level Extrinsic with attribute name InternalID doesn't store the value.

Can somebody confirm that we can work with it directly to get the deeper level? or we need to do a for or looping to get to that level so we can create the record in the Hashtable?

Thank you

Add a comment
10|10000 characters needed characters exceeded

Related questions

0 Answers

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.