I used Iterator and Script Mediator to calculate the sum of a student's grades.
I saw this problem i received each time the sum of 0 and noteis your say the totalnote does not take the variable note and increment For example if I put the value of totalnote =16 it is the sum of 16 and note of each row
My goal is to add up these 4 notes
Here is my code
<property name="totalnote" scope="default" type="INTEGER" value="0"/>
<iterate expression="//etudiants/etudiant">
<target>
<sequence>
<property expression="json-eval($.etudiant.note)" name="note" scope="default" type="INTEGER"/>
<log level="custom">
<property expression="get-property('note')" name="msg"/>
</log>
<script language="js"><![CDATA[{var i = parseInt(mc.getProperty("note")) ;
var totalnote = parseInt(mc.getProperty("totalnote")) ;
var totalnote = totalnote + i;
totalnote=totalnote.toString();
mc.setProperty("totalnote", totalnote);}]]></script>
<log level="custom">
<property expression="get-property('totalnote')" name="ms"/>
</log>
</sequence>
</target>
</iterate>
<respond/>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
</api>
and the result I received:
[2022-12-01 10:04:40,450] INFO {LogMediator} - {api:student} msg = 13
[2022-12-01 10:04:40,450] INFO {LogMediator} - {api:student} msg = 15
[2022-12-01 10:04:40,450] INFO {LogMediator} - {api:student} msg = 16
[2022-12-01 10:04:40,450] INFO {LogMediator} - {api:student} msg = 17
[2022-12-01 10:04:40,469] INFO {LogMediator} - {api:student} ms = 17
[2022-12-01 10:04:40,469] INFO {LogMediator} - {api:student} ms = 13
[2022-12-01 10:04:40,469] INFO {LogMediator} - {api:student} ms = 15
[2022-12-01 10:04:40,469] INFO {LogMediator} - {api:student} ms = 16