SOLVED

Power automate split variables into array output issue

Copper Contributor

Hi all, 

I'm still newish to Power Automate and am having an issue with a flow's output.

The form question being pulled from is multiple choice, so I want it to show as individual selected items in the Sharepoint register column, but I am getting responses mixed with extra characters like quotation marks, brackets, and commas.  It looks like it's coming from the splitting of the outputs, but I am not sure how to fix it.

 

In my flow, I have this set up before the apply to each:

Vroomkiwi_1-1687495713204.png

The formula in the Compose - format Injury is:

replace(replace(replace(body('Get_response_details')?['r63287d6142274127b7724d6ff63f2ac8'],']',''),'[',''),'"','')

 

When testing the flow, this is the output I get from a random selection of choices I used for testing:

Vroomkiwi_3-1687495990716.png

 

The formula in the Compose- split format Injury into an array is: split(outputs('Compose_-_format_Injury'),',')

 

When testing the flow, this is the output data from the split:

Vroomkiwi_4-1687496034347.png

 

and my Apply to each has the output from the split:

Vroomkiwi_2-1687495908318.png

with the test of the flow showing for one of the 3 variables:

Vroomkiwi_5-1687496273294.png

 

This is the returned result that pushes to the Sharepoint register:  

Vroomkiwi_0-1687495655974.png

 

Where is it going wrong?

 

 

2 Replies
best response confirmed by Vroomkiwi (Copper Contributor)
Solution

Hi @Vroomkiwi 

i am not sure what exactly you mean by "SharePoint register column".

But i think your variable "varInjury" needs to be of type "string", not "array" and you should use the "Append to string variable" action instead of the "Append to array variable" action.

Then you can pass a string that looks like this "Strain/sprain;#Dislocation;#Burn/scald" to your register.
Right now you are likely passing an array that gets serialized to  ["Strain/sprain;#","Dislocation;#","Burn/scald;#"] and that looks like the problem.

Best Regards,
Sven

PS:
You don't need that loop and the "varInjury" variable.
You are already using the "split" function to split your string into an array by the delimiter "," .

Then you can use the "join" function to join that array back to a string using the delimiter ";#"

join(split(outputs('Compose_-_format_Injury'),','),';#')




@SvenSieverding, thank you!!

 

I had only been taught to do the variables as an array, but changing it to a string was so much easier.

 

The flow now works properly, and when it pushes to the Sharepoint List, the destination column now shows each individual selection:

Vroomkiwi_0-1687733405947.png

 

Thank you for taking the time to assist me with this and teach me something new!

 

1 best response

Accepted Solutions
best response confirmed by Vroomkiwi (Copper Contributor)
Solution

Hi @Vroomkiwi 

i am not sure what exactly you mean by "SharePoint register column".

But i think your variable "varInjury" needs to be of type "string", not "array" and you should use the "Append to string variable" action instead of the "Append to array variable" action.

Then you can pass a string that looks like this "Strain/sprain;#Dislocation;#Burn/scald" to your register.
Right now you are likely passing an array that gets serialized to  ["Strain/sprain;#","Dislocation;#","Burn/scald;#"] and that looks like the problem.

Best Regards,
Sven

PS:
You don't need that loop and the "varInjury" variable.
You are already using the "split" function to split your string into an array by the delimiter "," .

Then you can use the "join" function to join that array back to a string using the delimiter ";#"

join(split(outputs('Compose_-_format_Injury'),','),';#')




View solution in original post