cancel
Showing results for 
Search instead for 
Did you mean: 

Integration Suite: Problem with Message Mapping in nested structures with the Groovy-Script

arthur_schewe
Explorer
0 Kudos
261

Hello dear experts,

I am trying to access nested values ​​in the GrovysScript using certain conditions in an Iflow as part of a message mapping in the Integration Suite, but it is not working and I have no idea how to solve the problem.

The following case or structure is present:

 

 

 

<ParameterValues>
	<ParameterCode>001</ParameterCode>
	<FieldListValue>
		<FieldListCode>1552</FieldListCode>
		<DescriptionValue>
			<LanguageCode>E</LanguageCode>
			<Description>123456</Description>
		</DescriptionValue>
	</FieldListValue>
	<Sequence>0</Sequence>
</ParameterValues>

<ParameterValues>
	<ParameterCode>002</ParameterCode>
	<FieldListValue>
		<FieldListCode>1223</FieldListCode>
		<DescriptionValue>
			<LanguageCode>E</LanguageCode>
			<Description>9881</Description>
		</DescriptionValue>
	</FieldListValue>
	<Sequence>0</Sequence>
</ParameterValues>

<ParameterValues>
	<ParameterCode>003</ParameterCode>
	<FieldListValue>
		<FieldListCode>4235</FieldListCode>
		<DescriptionValue>
			<LanguageCode>E</LanguageCode>
			<Description>34598</Description>
		</DescriptionValue>
	</FieldListValue>
	<Sequence>0</Sequence>
</ParameterValues>

 

 

 

When using message mapping in an array, I want to access an element <ParameterValues> which has the code 003 in the child node <ParameterCode>.

If the node has been found, the value 34598 from the node <Description> should be returned in the child node <DescriptionValue>. The structure I am mapping to is not nested but flat.

This is what the mapping for the fields looks like:

MMapping.jpg

The getValue() function in Groovy-Script looks like this:

 

 

 

def void getValue(String[] parameterValues, String[] descriptionValues, Output value, MappingContext context) {
	parameterValues.each{ parameterValue ->
		switch (parameterValue.ParameterCode) {
			case '003':
			    value.addValue(descriptionValues[0].Description);
			break
		}
	}
}

 

 

 

Which step is still missing or can I access the individual nodes so easily in the script?

Best regards
Arthur

View Entire Topic
arthur_schewe
Explorer
0 Kudos

Hello experts,

if anyone is interested, I solved the problem in the following way:

1) At the beginning of the processing, I use a script (Groovy) to save the necessary fields in a structured way (as JSON) in a parameter.

2) Later, after the message mapping, I adjust the target file using a script and the previously saved structure.

If anyone has a more elegant solution without scripts and only with the standard CPI functions, please write.

Best regards
Arthur