Skip to Content
0
May 24, 2019 at 03:40 AM

Message Mapping Scenario - Concatenation of Fields

169 Views Last edit May 21, 2020 at 03:30 PM 6 rev

Hi All,

Sample XML Payload

<Customer>
	<Name>John</Name>
	<id>CSC01</id>
	<city>Jersey</city>
	<details>
		<value1>ABC</value1>
		<value2>INF</value2>
	</details>
        <details>
		<value1>DEF</value1>
		<value2>HIK</value2>
	</details>
        <details>
		<value1>GHI</value1>
		<value2>INF</value2>
	</details>
</Customer>
<Customer>
	<Name>Peter</Name>
	<id>ITC01</id>
	<city>Newyork</city>
	<details>
		<value1>HIJ</value1>
		<value2>KLM</value2>
	</details>
</Customer>
<Customer>
	<Name>Parker</Name>
	<id>OPS01</id>
	<city>HONK</city>
	<details>
		<value1>JKO</value1>
		<value2>ADC</value2>
	</details>
</Customer>

Requirement is I have to concatenate all the <Value1> field whose <id> is "CSC01" and city is "Jersey"

I have done the mapping by checking the condition and written groovy script to concatenate all <value1> fields but value is always coming as "ABCDEFGHIHIJJKO" instead "ABCDEFGHI" . Seems like it concatenates all the <value1>. Condition is not evaluated. I know I am missing something silly. But couldn't find out.

Please help me out how to resolve this. Suggest me some hints to do this.

Thanks in Advance

Ansari