Skip to main content

Notifications

Community site session details

Community site session details

Session Id : VjAom7EVD0CayH1ZJNbA9G
Power Automate - Building Flows
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'.'.

Like (0) ShareShare
ReportReport
Posted on 9 Jun 2021 12:12:33 by

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

  • Community Power Platform Member Profile Picture
    on 10 Jun 2021 at 08:40:01
    Re: 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'.'.

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

    Thanks

  • Verified answer
    annajhaveri Profile Picture
    8,531 Most Valuable Professional on 09 Jun 2021 at 13:20:51
    Re: 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'.'.

    @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
    on 09 Jun 2021 at 12:41:05
    Re: 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'.'.

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

  • annajhaveri Profile Picture
    8,531 Most Valuable Professional on 09 Jun 2021 at 12:36:55
    Re: 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'.'.

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

  • Community Power Platform Member Profile Picture
    on 09 Jun 2021 at 12:32:24
    Re: 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'.'.

    @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 09 Jun 2021 at 12:24:00
    Re: 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'.'.

    @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.

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,518 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,692 Most Valuable Professional

Leaderboard
Loading started