Select to view content in your preferred language

Power Automate to Microsoft List, Replicate Name Error

1042
5
Jump to solution
03-14-2024 10:18 AM
spf999
by
Emerging Contributor

Hello, 

I am creating a Microsoft Power Automate Flow to take my Survey123 submissions and create new line items in my Microsoft List.

In this specific Survey123, I have a field for replicate number, which if the answer is >1, will require a repeated replicate name field. The number of repeats of the replicate name field corresponds to the numeric value entered in the replicate number field. 

As it stands in my flow, the number of line items created is related to the number of replicates. All is running smoothly except, when I try to submit a survey response with only one replicate, the flow fails.

I know that this has something to do with the "Select an output from the previous step" section in the apply to each section of the flow. However, if I change this dynamic content from the repeat replicate names field, the flow continues to fail for single replicates, or will not import replicate names for more than 2 replicates. 

How do I resolve my issue to have the correct number of line items for the number of replicates with the names imported and be able to have the flow run with only one replicate too? 

Below are screen shots of my flow as well as the failed error. 

0 Kudos
1 Solution

Accepted Solutions
abureaux
MVP Frequent Contributor

Had a look. Didn't clue in right away, but seeing it "in person" helped. The issue is that the repeat only appears when a number >1 is entered. That means the user can enter 1, submit the form, and your described Power Automate issue will occur.

abureaux_4-1710779686224.png

This being the case, you will need to test for the repeat and then branch your flow accordingly. You can select the repeat in Power Automate:

abureaux_5-1710781155105.png

And then use that in a Condition similar to this:

abureaux_6-1710781184483.png

When the repeat is empty, it will do one thing, and when it contains data, it will do something else.

Beyond that, here are a couple template things, in case you didn't already know (I attached the XLSX):

  • notes don't need names. I deleted the name for sampret_disclaim.
  • Any field with a green triangle in the appearance is not valid. I removed these.
    abureaux_0-1710777407638.png
  • When setting a default for a select, you need to use the list item's name, not its label. That is why your field blank question wasn't working (red is bad):
    abureaux_1-1710777474314.png
  • Also on the note of field blank, it was set to the yes_yes list rather than the yes_no list. I assumed that was a mistake since you had the default set to 'no' so I swapped it back to the yes_no list.
  • I'm thinking you may have copy-pasted or dragged some items around. The data validation wasn't working properly. Specifically, I wanted to make the key question here, ${sampinfo_reps}, a little easier to find/use since it's an integer with a hidden repeat. I gave it the "numbers" appearance, which is valid, but it got flagged. Since I didn't want to mess around with the template, I just copy-pasted your survey as text into a brand new template.
  • For ${collect_date}, I'd suggest using a date field. To minimize user error, you can use a separate calculate with this formula to get your indicated format (more info) format-date(${collect_date},'%Y-%m-%d')
    • Alternatively, if you want this to remain as a text field, you can use an input mask to help out the user: 9999-99-99;#
  • I saw you had a pH scale. I gave it some pretty formatting because... it's pretty
    abureaux_3-1710778641447.png
  • Regarding "Field Comments", be aware that this is the default 255 character length. Depending on the user, they may need far more that 255 characters. If you are intentionally limiting this field, that's fine. But if you want to allow more characters, I highly recommend you change this now rather than later. Changing a field's character length will result in Connect wanting to wipe the database.
  • Using formula like if(${sampinfo_type}='filter','yes','') is dangerous. I highly recommend using this format instead: if(selected(${sampinfo_type},'filter'),'yes',''). This actually comes into play with your select_multiple. It will not function as expected with the current formula. Swapping to the selected() version will fix this issue.
  • Hidden field's "required" parameter is ignored. I.e., a hidden field with required=yes will not cause a problem. As such, I simplified several field's required parameters (e.g., ${sampinfo_filterother}) by just changing them to required=yes
  • When setting things like constraints that self-reference, you can use . instead of the field name. E.g., you can change ${sampinfo_reps}>0 to .>0. This is faster to enter, and easier to read.

View solution in original post

0 Kudos
5 Replies
abureaux
MVP Frequent Contributor

From the screen shot, your repeat doesn't exist under this scenario. Are you able to include your XLSX so I can get a better idea of the workflow?

Ideally, your repeat in S123 will always exist and will always have at least one record (aka, be required).

If, when you have one item, the repeat doesn't exist, then you will need a condition within Power Automate to detect for a null repeat, and then do something else.

0 Kudos
spf999
by
Emerging Contributor

Hello here are the screenshots of the XLSX. Screenshot 1.pngScreenshot 2.pngscreenshot 3.png

0 Kudos
abureaux
MVP Frequent Contributor

A quick glance at the screen shots seems to indicate that:

  • ${saminfo_reps} is required and must be >0
  • ${saminfo_repinfo} is required if ${saminfo_reps}>0 and the number of repeat items is equal to ${saminfo_reps} (which is a positive integer).

Given that, the ${saminfo_repinfo} array should theoretically never be null, meaning your flow should at least get beyond that point. But, that obviously isn't the case. If you could attach the actual XLSX, I could recreate this.

(Side note, but it looks like you can just make ${saminfo_repinfo} required rather than conditionally required)

0 Kudos
spf999
by
Emerging Contributor

Here is the XLSX, thank you for your help!

0 Kudos
abureaux
MVP Frequent Contributor

Had a look. Didn't clue in right away, but seeing it "in person" helped. The issue is that the repeat only appears when a number >1 is entered. That means the user can enter 1, submit the form, and your described Power Automate issue will occur.

abureaux_4-1710779686224.png

This being the case, you will need to test for the repeat and then branch your flow accordingly. You can select the repeat in Power Automate:

abureaux_5-1710781155105.png

And then use that in a Condition similar to this:

abureaux_6-1710781184483.png

When the repeat is empty, it will do one thing, and when it contains data, it will do something else.

Beyond that, here are a couple template things, in case you didn't already know (I attached the XLSX):

  • notes don't need names. I deleted the name for sampret_disclaim.
  • Any field with a green triangle in the appearance is not valid. I removed these.
    abureaux_0-1710777407638.png
  • When setting a default for a select, you need to use the list item's name, not its label. That is why your field blank question wasn't working (red is bad):
    abureaux_1-1710777474314.png
  • Also on the note of field blank, it was set to the yes_yes list rather than the yes_no list. I assumed that was a mistake since you had the default set to 'no' so I swapped it back to the yes_no list.
  • I'm thinking you may have copy-pasted or dragged some items around. The data validation wasn't working properly. Specifically, I wanted to make the key question here, ${sampinfo_reps}, a little easier to find/use since it's an integer with a hidden repeat. I gave it the "numbers" appearance, which is valid, but it got flagged. Since I didn't want to mess around with the template, I just copy-pasted your survey as text into a brand new template.
  • For ${collect_date}, I'd suggest using a date field. To minimize user error, you can use a separate calculate with this formula to get your indicated format (more info) format-date(${collect_date},'%Y-%m-%d')
    • Alternatively, if you want this to remain as a text field, you can use an input mask to help out the user: 9999-99-99;#
  • I saw you had a pH scale. I gave it some pretty formatting because... it's pretty
    abureaux_3-1710778641447.png
  • Regarding "Field Comments", be aware that this is the default 255 character length. Depending on the user, they may need far more that 255 characters. If you are intentionally limiting this field, that's fine. But if you want to allow more characters, I highly recommend you change this now rather than later. Changing a field's character length will result in Connect wanting to wipe the database.
  • Using formula like if(${sampinfo_type}='filter','yes','') is dangerous. I highly recommend using this format instead: if(selected(${sampinfo_type},'filter'),'yes',''). This actually comes into play with your select_multiple. It will not function as expected with the current formula. Swapping to the selected() version will fix this issue.
  • Hidden field's "required" parameter is ignored. I.e., a hidden field with required=yes will not cause a problem. As such, I simplified several field's required parameters (e.g., ${sampinfo_filterother}) by just changing them to required=yes
  • When setting things like constraints that self-reference, you can use . instead of the field name. E.g., you can change ${sampinfo_reps}>0 to .>0. This is faster to enter, and easier to read.
0 Kudos