cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mihaimanea
Helper I
Helper I

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

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

1 ACCEPTED SOLUTION

Accepted Solutions

@mihaimanea  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?

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.

View solution in original post

6 REPLIES 6
annajhaveri
Super User
Super User

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

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.

@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

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

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.
mihaimanea
Helper I
Helper I

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

@mihaimanea  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?

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.

View solution in original post

mihaimanea
Helper I
Helper I

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

Thanks

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (2,361)