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 Platform Community / Forums / Power Automate / Flow save failed with ...
Power Automate
Answered

Flow save failed with code 'InvalidVariableInitialization' and message 'The variable action 'Initialize_variable' of type 'InitializeVariable' cannot be nested in an action of type 'Apply_to_each'.'.

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi,

What does this error mean and how to solve it?

I want to get the info of a Sharepoint row and pass it back to Powerapps in order to do something with that data using Power automate.c3.PNG

Categories:
I have the same question (0)
  • annajhaveri Profile Picture
    8,531 Most Valuable Professional on at

    @Anonymous  the error says that you cant add "Initialize Variable" action inside apply to each action. So add "Initialize Variable" action before the Apply to each action, and then add "Set Variable" action inside Apply to each action, to set the value of variable.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @annajhaveriI did what you suggest. It works without the respond to powerapps flow, but i need that flow to send that data to my powerapps.c4.PNG

  • annajhaveri Profile Picture
    8,531 Most Valuable Professional on at

    @Anonymous  what value you want to return in the Respond to a PowerApp or Flow?

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @annajhaveriI want to return data from SharePoint to PowerApps.
    A row in SharePoint has this data (id, name, surname, age, location, etc)

  • Verified answer
    annajhaveri Profile Picture
    8,531 Most Valuable Professional on at

    @Anonymous  using "Respond to a PowerApp or Flow" action you cant return an array, so i would suggest to change the type of variable to string. And instead of Set Variable use "Append to string variable" action and use concat expression to concat values of id, name surname, age, location, etc, example expression as below:

    concat(items('Apply_to_each')?['ID'],', ',items('Apply_to_each')?['Title'],', ',items('Apply_to_each')?['Name'])

     

    See how actions will be added in flow in screenshot below

    annajhaveri_0-1623244816890.png

    Are you using filter query on Get Items to get specific item from list?

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @annajhaveriOk, it works as you stated. I managed to build a string with a comma separator.

    Thanks

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 262 Super User 2026 Season 1

#2
Haque Profile Picture

Haque 227

#3
Expiscornovus Profile Picture

Expiscornovus 225 Most Valuable Professional

Last 30 days Overall leaderboard