# Revision history [back]

If you know you will always have exactly two entries in the paymentCalculations array, you can use an Expression Evaluator to add them. Set the Field Expression to:

\${record:value('/paymentCalculations[0]/netPay') + record:value('/paymentCalculations[1]/netPay')}


If there are a variable number of entries, you will need to do this in a script evaluator. For example, in Jython, it would be:

for record in records:
try:
# Loop through paymentCalculations array, summing the values
# into totalNetPay
totalNetPay = 0
for pay in record.value['paymentCalculations']:
totalNetPay += pay['netPay']

# Set the totalNetPay field in the record
record.value['totalNetPay'] = totalNetPay

# Write record to processor output
output.write(record)

except Exception as e:
# Send record to error
error.write(record, str(e))