cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
kamotekid
Frequent Visitor

Update Sharepoint list based on dynamic array from Forms

Hi!

 

I have a Forms form that accepts responses and then gets listed into a Sharepoint list.

One of the questions allows multiple selection, and produces a different number of responses depending on the situation, maximum of 10.  My flow splits that into an array of items and then I need to get each array element into an SP list.

 

I am usually able to list the first array element into the SP list, via a simple expression variables('ArrayToSplit')[0]

My challenge is making sure the flow can get each of the rest of the elements in there.  I think I should use 'Do until' instead of an 'Apply to each' using the length of the array as a counter, but I'm a little confused.

 

What I have right now is the screenshot below, where I check if each line is empty.

kamotekid_0-1624386867285.png

Here's the formula I tried: 

if(empty(variables('ArrayToSplit')[1]),'',variables('ArrayToSplit')[1])

 

I'm getting an error when the expression tries to evaluate a line outside the number of elements of an array.

The template language expression 'if(empty(variables('ArrayToSplit')[1]),'',variables('ArrayToSplit')[1])' cannot be evaluated because array index '1' is outside bounds (0, 0) of array.

 

Please help me, what's your recommendation for this situation. Thanks

2 REPLIES 2
RezaDorrani
Dual Super User II
Dual Super User II

Hi @kamotekid ,

 

Check and see if this video helps https://youtu.be/kbqXsKPTmZk

 

--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

Thanks,
Reza Dorrani, MVP
YouTube
Twitter

kamotekid
Frequent Visitor

@RezaDorrani thanks for the video link.  I watched it and learned a lot, so I bookmarked it.

 

I apologize, I think I made a mistake with the problem mentioned above. Here's the Forms question that's giving me the headache:

kamotekid_0-1624389874822.png

It's a long answer question, where it can get up to 10 answers max separated by commas.  My flow then splits that string by commas, trims out any spaces, and puts them into an array with the expression: split(trim(variables('StringToSplit')),',')

 

Then I split that array into elements to put into each of the SP columns in the original screenshot.  The reason is because that SP list is also being used by a different flow (not mine), and should accept only one answer per column.  

 

It sounds convoluted, but I didn't have much control over the Forms and SP portions, just tasked with an automation to push the Forms data out into SP.

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

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.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Top Solution Authors
Users online (1,334)