Skip to content

lost with an expression #716

Open
Open
@jviure

Description

@jviure

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions