AnsweredAssumed Answered

XML profile - repeatable field with attribute mapping

Question asked by MartinFilakovsky7421 on Jun 17, 2014
Latest reply on Jun 17, 2014 by Adam Arrowsmith

     I have a request XML message with ONE field "cField" which could have different attribute "name". This field is repeatable. Example:
     <request>
         <cField name="Test1">Value1</cField>
         <cField name="Test2">Value2</cField>
         <cField name="Test3">Value3</cField>
     </request>
0EM40000000Pbwr

     I would like to do mapping to have a result like this:
     <response>
         <test1>Value1</test1>
         <test2>Value2</test2>
         <test3>Value3</test3>
     </response>

     I tried in the mapping use cusotm scripting where as input I have cField value and his attribute name and have three output test1, test2 and test3. The script looks:
     if(name == 'Test1') {
         test1 = cField
     }
     else if(name == 'Test2') {
         test2 = cField
     }
     else if(name == 'Test3') {
         test3 = cField
     }

     Those three output values I mapped to response XML structure. When I run the test, it will generate three documents instead of one:
     1. <response>
         <test1>Value1</test1>
     </response>
     2. <response>
         <test2>Value2</test1>
     </response>
     3. <response>
         <test3>Value3</test1>
     </response>

     Is it possible to have mapping for that to have just one document as a result?

     Thanks,
     Martin.

Outcomes