Open
Description
Hi, I m getting crazy with this jsonata expression, I don't know why the $append seems not working, the $uniqueIds is always empty at the output indistinctly the lookup value (true, false..), the total variable the same, some idea how to continue? I only need those values updated inside the $map.
(
$uniqueIds := [];
$total := 0;
$map(products.agreements, function($agreement, $i) {
($lookup($uniqueIds, $agreement.id) and $agreement[$i].offerType = "OP") ?
$uniqueIds := $append($uniqueIds, [$agreement.id]) :
$total := $total + $agreement.totalAmount
}
);
{
"uniqueIds" : $uniqueIds,
"total": $total
}
)
some clue? thanks