cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Alanisp22
Helper II
Helper II

Split Form Multiple Choice Question Answers into Separate Columns in SharePoint List

Hello,

 

I am trying to set up a flow that will get the response details from a SharePoint Form and split the multiple-choice question answers into separate list columns in SharePoint. My main issue with how I have it currently set up is that my flow fails if a user submits less than 3 answer selections from the multiple-choice question. I believe the issue is that I am specifying to feed over exactly 3 answer selections into 3 separate columns by using variables('Choice')[0],  variables('Choice')[1],  and variables('Choice')[2], so my flow is failing if the answer selection is less than 3. Is there anything I can do to make sure my flow doesn't fail if it doesn't locate variables('Choice')[1] and variables('Choice')[2]?
In other words, how can I set my flow up to split multiple choice question answers from a form into separate columns in a SharePoint list and not fail if less than 3 choices were selected (I only have 3 possible answer selection options in the question and 3 separate columns they feed into in SharePoint)?

Here is the error details:

InvalidTemplate. Unable to process template language expressions in action 'Create_item' inputs at line '1' and column '2831': 'The template language expression 'variables('Choices')[2]' cannot be evaluated because array index '2' is outside bounds (0, 1) of array. Please see https://aka.ms/logicexpressions for usage details.'.

1 ACCEPTED SOLUTION

Accepted Solutions
Jronash
Impactful Individual
Impactful Individual

Coalesce is your friend. You can provide it with a list of variables or values, and it will return the first one that is not null.

 

For instance:

coalesce(variables('Choices')[2], 'Default value')

This will return the value of the third Choices item if it exists.  If it is null, it will return 'Default value'.

View solution in original post

2 REPLIES 2
Jronash
Impactful Individual
Impactful Individual

Coalesce is your friend. You can provide it with a list of variables or values, and it will return the first one that is not null.

 

For instance:

coalesce(variables('Choices')[2], 'Default value')

This will return the value of the third Choices item if it exists.  If it is null, it will return 'Default value'.

@Jronash  YAY!! That worked! Thank you so much!!!! 😁

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

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

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (3,229)