web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Automate
Unanswered

Apply to Each Error

(0) ShareShare
ReportReport
Posted on by 3,295

Hi there, new in Flow

I am trying to merge my Collection from PowerApps to my Word Document Template. I think that I finally get the schema correctly but I am getting this error:

 

ExpressionEvaluationFailed. The execution of template action 'Apply_to_each' failed: the result of the evaluation of 'foreach' expression '@variables('orderCollection')' is of type 'String'. The result must be a valid array.

 

Could someone point me in the right direction or a youtube tutorial to follow?

Thank you kindly

 

flow1.PNGflow2.PNGflow3.PNG

 

 

Categories:
  • Jronash Profile Picture
    827 on at

    The data that you are getting from your PowerApp (varOrderCollection) is set to come in as a string.  You can see in your 'varOrderCollection' action that the variable is set to 'string', not 'array'.  The error message you are getting is because you are trying to loop a string, which is not possible.

     

    In order to loop through your data, you will either have to convert it to an array, or set your Flow and PowerApps up so that the data is sent as an array instead of a string.

     

    Could you post an example of what the data looks like when it comes from PowerApps?  Also, if you could post the formula in PowerApps that is sending the data, that could be helpful as well.

  • Sajarac Profile Picture
    3,295 on at

    Hi, thanks for your prompt response

     

    Here is the data requested:

     

    txtSuppComm: DataCardValue79.Text,
    txtPTerms: DataCardValue78.Selected.Value,
    txtStartDate: DataCardValue81.SelectedDate,
    txtEndDate: DataCardValue82.SelectedDate,
    txtShDateDetails: DataCardValue83.Text,
    txtPacker: DataCardValue88.Selected.Value,
    txtLabel: BrowseGallery1.Selected.LabelType.Value,
    txtConditions: DataCardValue84.Text
    }
    );
    Clear(collTblOrder);
    PopulateWordTemplate.Run(
    JSON(
    GeneratePO,
    JSONFormat.IndentFour
    )
    );
    //Clear(GeneratePO);

     

    {
        "type": "array",
        "items": {
            "type": "object",
            "properties": {
                "LblToday": {
                    "type": "string"
                },
                "txtCity2": {
                    "type": "string"
                },
                "txtConditions": {},
                "txtConsecutive": {
                    "type": "string"
      etc..

     

  • Jronash Profile Picture
    827 on at

    What happens if you set your Apply to Each loop to run from the output of the Parse JSON action, rather than your varOrderCollection variable?

     

    If that doesn't work, please post the output of the Parse JSON action.

  • Sajarac Profile Picture
    3,295 on at

    I have added a compose action and after that the populate a Word Template.

    It seems like is fine but after I am trying to create a file in my sharepoint library and I am getting error in the File Content. in that part I should be able to pick "Microsoft Word Document" but nothing appears

     

    flowissue1.PNG

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 302 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 263

#3
Henil Profile Picture

Henil 115

Last 30 days Overall leaderboard