Loading
Agentforce is temporarily unavailable. Please try again later or visit Help topics below. For additional support, please contact your local support number for assistance. Thank you!
Ongoing maintenance for Salesforce HelpRead More
Feature degradation | Gmail Email delivery failureRead More

java.lang.IllegalArgumentException: Foreach does not support java.util.Map with no collection expression

Publish Date: Jul 14, 2025
Resolution

SYMPTOM

When attempting to iterate through a payload using a For Each scope in Mule 4, you may be facing an error showing:
java.lang.IllegalArgumentException: Foreach does not support 'java.util.Map' with no collection expression. To iterate over Map entries use '#[dw::core::Objects::entrySet(payload)].
 

CAUSE

The issue is caused by invalid data structure being used to trigger the For Each scope. For Each expects a valid array of data. Without a valid array of data, or if invalid data is used to trigger the For Each, you may see this error.

SOLUTION

In order to resolve the issue, you need to review your application design. Specifically, you need to ensure proper data is used to trigger the For Each scope in the form of a valid array of data. 

Typically, this would involve adding a Transform Message operation and using something like a DataWeave map function to map your data to an array. After this is updated, you should no longer see the issue.
Knowledge Article Number

001119604

 
Loading
Salesforce Help | Article