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
Dual Super User

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
 WHAT’S NEXT AT MICROSOFT IGNITE 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Register for a Free Workshop.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Users online (3,345)