Reputation: 27
Can anyone kindly provide the DataWeave logic for the below output structure based on the two Inputs resultSet1 and resultSet2. if the id is matched change the status to true and by default, the status is false?
resultSet1 = [{ id: "12334", }, { id: "13357", } ]
resultSet2 = [ { id: "12334", status: false }, { id: "11521", status: false }, { id: "13357", status: false }
final output: [ { id: "12334", status: true }, { id: "11521", status: false }, { id: "13357", status: true } ]
Thanks in advance!
Upvotes: 0
Views: 136
Reputation: 76
this solution iterates resultSet2
and for each item checks if the ID is in the list of IDs of resultSet1
resultSet2 map {
id: $.id,
status: resultSet1.id contains $.id
}
Upvotes: 2