Assign Element - append option

Mirjana's picture
If you have ever asked yourself what an append parameter is used for in the Assign Element, here is a simple example that could explain it. It works the same in the Output or Input messages inside of services configuration.

 
BPML, 3 assigns without append option:
 
<process name="default">
 <sequence>
    <assign to="AAA">aaa</assign>
    <assign to="BBB">bbb</assign>
    <assign to="AAA">a new value of AAA element</assign>
 </sequence>
</process>
 
Process Data after the 1st assign:
 
<?xml version="1.0" encoding="UTF-8"?>
<ProcessData>
 <AAA>aaa</AAA>
</ProcessData>
 
Process Data after the 2nd assign:
 
<?xml version="1.0" encoding="UTF-8"?>
<ProcessData>
 <AAA>aaa</AAA>
 <BBB>bbb</BBB>
</ProcessData>
 
Process Data after the 3rd assign (AAA is overwritten):
 
<?xml version="1.0" encoding="UTF-8"?>
<ProcessData>
 <AAA>a new value of AAA element</AAA>
 <BBB>bbb</BBB>
</ProcessData>
 
BPML, 3 assigns, the last one with append option:
 
<process name="default">
 <sequence>
    <assign to="AAA">aaa</assign>
    <assign to="BBB">bbb</assign>
    <assign to="AAA" append="true">a new value of AAA element</assign>
 </sequence>
</process>
 
Process Data after the 1st assign:
 
<?xml version="1.0" encoding="UTF-8"?>
<ProcessData>
 <AAA>aaa</AAA>
</ProcessData>
 
Process Data after the 2nd assign:
 
<?xml version="1.0" encoding="UTF-8"?>
<ProcessData>
 <AAA>aaa</AAA>
 <BBB>bbb</BBB>
</ProcessData>
 
Process Data after the 3rd assign (AAA is appended):
 
<?xml version="1.0" encoding="UTF-8"?>
<ProcessData>
 <AAA>aaa</AAA>
 <BBB>bbb</BBB>
 <AAA>a new value of AAA element</AAA>
</ProcessData>
 
If we assign an XML element in the Process Data by assign with append=”true” option, and such element already exists, then a new one will be added. If append is set to false, an existent element in Process Data will be overridden by a new one.