Skip to main content
Community site session details

Community site session details

Session Id : lc8JhWZ/ch6qTiU/thexXv
Power Automate - Building Flows
Answered

How to create a valid array?

Like (0) ShareShare
ReportReport
Posted on 14 Dec 2021 08:22:26 by 57

Problem: The execution of template action 'Apply_to_each_10' failed: the result of the evaluation of 'foreach' expression ' @{createArray('1','2','3','4','5','6','7','8')}' is of type 'String'. The result must be a valid array.

Jo9_0-1639470041286.png

I have tried multiple solutions but the flow still trigger error.

Please help.

 

Thank you.

Regards,

Jo

  • Verified answer
    Paulie78 Profile Picture
    8,416 Moderator on 14 Dec 2021 at 10:18:44
    Re: How to create a valid array?

    Your createArray expression should work fine in the apply to each. What I suspect is that you have a character in the field (such as a space) which is not visible. 

     

    • Delete the expression.
    • Put the cursor in the field and hold the delete key until you are sure there is nothing left.
    • Paste the expression back in again.

    Expression should just be:

    createArray('1','2','3','4','5','6','7','8')

    Or perhaps this would be simpler:

    range(1,8)

    Then you should be set. It is the presence of extra characters which is changing your valid array into a string.

     

    Blog: tachytelic.net

    YouTube: https://www.youtube.com/c/PaulieM/videos

    If I answered your question, please accept it as a solution 😘

     

  • VictorIvanidze Profile Picture
    12,538 on 14 Dec 2021 at 08:48:35
    Re: How to create a valid array?

    Sorry it seems you just do not understand what is the array. The "Outcome" is a string.

    What are you trying to achieve?

  • Jo9 Profile Picture
    57 on 14 Dec 2021 at 08:42:24
    Re: How to create a valid array?

    I have tried initialize the array as variable in earlier flow. But the similar error has been trigger.
    Beginning of flow: Initialize an array variable:

    Jo9_0-1639471176615.png
    Middle of flow: The output from previous flow: I put the initialized array variable

    Jo9_1-1639471238327.png

     

    Thank you.

  • VictorIvanidze Profile Picture
    12,538 on 14 Dec 2021 at 08:36:02
    Re: How to create a valid array?

    Do not create an array in "foreach". Initialize the array as a variable earlier.

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

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 2

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 2

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 2

Loading started