2024 Jun 25 12:51 PM - edited 2024 Jun 25 4:12 PM
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:
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
75 | |
10 | |
10 | |
10 | |
10 | |
9 | |
8 | |
7 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.