[solved] Using a field value in other field (in the same xml struct)

Hi,
I read xml file, I have

<field1>Value</field1>

and in <field10> I want to have ABC Network - ABC.comValue (the value from <field1>)

How to implement it in datamapper?

Thanks in advance.

This can be achieved by executing the following steps:

  1. Open the Designer application
  2. Create a new (XML File) DataMapper configuration
  3. Click with the right mouse button on <field10> in the XML viewer pane and select the option Add Extraction
  4. Change the Based on option in the (Extract Step) Step Properties pane from Location to JavaScript
  5. Apply the following JavaScript code to the Expression field and click on Apply to close the Edit script - Extraction - field10 window and to apply the JavaScript code:
let field1 = data.extract("./record[1]/field1[1]");
let field10 = data.extract("./record[1]/field10[1]");

if (field1) field10 += field1;

field10;

When performing the above steps, I expect the XML data to look something like this:

<?xml version="1.0" encoding="UTF-8"?>
<records>
	<record>
		<field1>Value</field1>
		<!-- [...] -->
		<field10>www.example.com?uid=</field10>
	</record>
</records>

Great! Thank you very much!

1 Like