DataWeave tip: Use Arrays module import to partition records into accepted and rejected lists

A DataWeave developer encountered an unresolved reference error when using the partition() function without explicitly importing the Arrays module. The fix requires adding 'import * from dw::core::Arrays' to the script header before calling partition(). The technique splits a list of order records into success and failure groups based on email validation, then remaps these to domain-friendly keys like 'accepted' and 'rejected'. A retryCount field is also derived using sizeOf() on the failure partition. The solution was demonstrated using DataWeave CLI 2.12.2 against a sample payload of five order records.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in