cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Dhiran
Helper III
Helper III

Accessing Array elements

I have a flow which looks at incomng email from a specific address and creates an array of the subject heading using the Split command. I would like to the 2nd element of the array in the next step to create an calendar event. 

 

If i just place the arrary in the next element I can see the following structure ["Text element 1","Text element 2"] 

 

Is there a way I can get only "Text Element 2" in my next step.

 

Here is a screen shot of steps

Split Command.png

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @Dhiran,

Please take a try with the following workaround:

  • Add Variables-> Initialize variable action after “Compose” action, Name set to TextArray, Type set to Array, Value set to output of “Compose” action.
  • In “Create event (V2)” action, type the following formula in Subject parameter:
@variables('TextArray')[1]

Image reference:2.JPG

 

The flow works successfully as below:3.JPG

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

9 REPLIES 9
v-xida-msft
Community Support
Community Support

Hi @Dhiran,

Please take a try with the following workaround:

  • Add Variables-> Initialize variable action after “Compose” action, Name set to TextArray, Type set to Array, Value set to output of “Compose” action.
  • In “Create event (V2)” action, type the following formula in Subject parameter:
@variables('TextArray')[1]

Image reference:2.JPG

 

The flow works successfully as below:3.JPG

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Hi @v-xida-msft (Kris) that worked so thank you. The only issue was the expression would not take the "@" symbol but I could just addd the line without the "@".

worked perfectly! 

Thanks,

Hasan

philkky
Frequent Visitor

I want to do something similar, I have an array and I was to loop through each entry putting the value in to an HTML table. In this case the formula 

 

@variables('TextArray')[1]

 

 Will keep giving me the same value for the number of items in the array, how do I increment this number or should I take a different approach?

bbolotin
New Member

Does anyone know how you would do this (reference an item in array) when there is a variable amount of items. The array is created from a checkbox selection in a Microsoft form and I would want to loop through and create a work item for each instance(item they checked.

After the array is created, you can get the length of the array and then loop through it. 

kamotekid
Frequent Visitor

Hi! Would you create for me a sample flow?
I'm trying to do the exact same thing, with a variable array based on MS Forms entries.  In my flow I've already initialized a variable with the formula length(outputs('FormsQuestion2')) after splitting the string from MS Forms.  Next step for me is to update a sharepoint list with each array element, and wondering what the most efficient way is since the length can be variable depending on the Forms response.

Thank you!

Here is my attempt. If you use a compose statement to split your Question 2 it will provide you with an array. and then use this flow

 

Dhiran_0-1628506034181.png

 

kamotekid
Frequent Visitor

Thank you!  I adapted your sample above and now I'm able to work through the array with variable lengths.

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

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.

Top Solution Authors
Users online (1,014)