I'm using the iterate mediator for saving files. For this I need a counter for the iterations. I tried to create an property outside of the iteration and use the script mediator to count the iterations like follows.
<property name="AttachmentCounter" value="0"/>
<iterate xmlns:ns="http://org.apache.synapse/xsd" continueParent="true" expression="$body/ticket/IctAttachments/item" id="IctAttachments" sequential="true">
<target>
<sequence>
<script language="js">
<![CDATA[var counter = mc.getProperty("AttachmentCounter");
counter = parseInt(counter) + 1;
mc.setProperty("AttachmentCounter", counter);]]>
</script>
<log>
<property name="AttachmentCounter:" expression="get-property('AttachmentCounter')"/>
</log>
</sequence>
</target>
</iterate>
The Problem is, that I get the same number after every iteration. Whats the reason for this? Is there a mistake I don't see? Maybe there is another way I couldn't find while searching the internet.