1

how can i create map variable in dataweave from 2 lists where the first element in first list should be the key in the map and first element from second list should be the value in the map and so on...

Below script is throwing error.

%dw 1.0 %output application/json %var accountIdMap = { (payload.*accountIdList): payload.*accountNameList }

1 Answer 1

1

Assuming the order and number of elements in both lists are same, you should map on one list and then create elements -

%var accountIdMap = (payload.accountIdList map ('$':payload.accountNameList($$)))

$ = current element in iteration from accountIdList $$ = index of current iteration from accountIdList. Get element at same index from other list.

Sign up to request clarification or add additional context in comments.

2 Comments

I get the below errorCannot coerce a :array to a :function (com.mulesoft.weave.mule.exception.WeaveExecutionException). Message payload is of type: WeaveMessageProcessor$WeaveOutputHandler
My mistake ... Change it to payload.accountNameList[$$]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.