0

I have a flow that's retrieving the values from an MS Form and then pushing them to a SharePoint Online list, and it's running without errors:

Overall flow

The problem is that I have 10 different "Description" fields in my form (the user should only complete one, based on the category they've selected), but only want a single "Description" column in my SharePoint list. When I write the data to the SharePoint list, though, that field is NULL.

To insert the correct Form field into the list, I've created a variable (string) and used a Switch Case to identify and use the correct Description field from the Form, based on the Category field in the Form. I thought this would be a better choice in terms of maintenance than leaving someone to comb through a 10-layer deep nested IF statement.

I'm running the Flow with data using the "School or office supplies, like stationery" category. The corresponding description field is populated from the Form (in the Get Response Details section of the Flow):

Description field in Get Response Details

It's a relatively small value (maybe 100 characters). So, before the Switch control I initialize a variable to hold the "3,000 binders..." text:

Initialize variable

I then have a Switch that will choose a case based on the Category value. It is showing the correct category:

Switch output

And it is choosing the correct Case. The problem is, when I try to Set Variable within the case, no values are coming through.

Correct case, but variable not populated

This is how I have the Set Variable control configured:

Set variable configuration

This is the statement for the value field.

outputs('Get_response_details')?['body/r3b317cf53b8d429e808cf637cee8ae25']

The ID matches up to the one shown above, with the description field that I want to use. I'm using this expression instead of selecting the dynamic content field directly because I have 10 fields that all say "Donation Description" in Forms, and it was easier just to code it than to try to figure out which one I needed in the Dynamic Content wizard in Flow. Elsewhere, though, they work the same way (picking the dynamic content item or writing an expression defining it), so I'm assuming they do here, too.

So:

  1. I'm getting the field that I need from the Forms data
  2. I'm setting up a string variable to hold it
  3. I'm using a switch case to select which Forms field should populate the variable
  4. The switch is selecting the correct case
  5. The set variable action isn't retrieving or populate the data into the variable

I haven't worked much with variables (and not at all with the switch/case control) but I'm trying to get away from stuffing everything into conditional statements to make it more transparent. Any idea where I'm going wrong in setting my variable?

1 Answer 1

0

So, turns out that it was a simple solution, but a frustrating one.

All I had to do was move the Initialize Variable block from the third position to the second one (right after my trigger), so my new order is:

flow overview

Now, when I run the flow on the same data, it does populate the variable as expected:

populated variable

I'm glad I got it working, but can't understand at all why Flow won't recognize a variable initialized in the third step instead of the second one! There's no data dependency or other apparent reason beyond "that's just the way we made it". If anyone knows if there's a functional reason for this I'd love to understand it more, so please comment.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.