cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

Splitting array invalid

I have apply to each loop which creates filenames, i used append to variable array to create a long string of all filenames that got created "name1.zip,name2.zip,name3.zip,". Because i want to use these filenames outside my for each loop to compare to a list later on in my steps. i added a comma to the end of each filename ","  to use as seperator, so i can split them later

 

i want to split this to:

name1.zip

name2.zip

name3.zip

 

Its saying my expression is invalid and i don't understand why. i used:  split(variables('Array of file names'),",")

Kryptic_0-1600253796328.png

 

7 REPLIES 7
Highlighted
Dual Super User III
Dual Super User III

Re: Splitting array invalid

Hi

It seems you are using double quotes to wrap the comma inside your split() based WDL expression. If so, try with single quotes instead

split(variables('Array of file names'),',')

Hope this helps



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



Highlighted
Helper I
Helper I

Re: Splitting array invalid

Thanks, that worked. I ran into another problem:

You can see the filename i create, then theyre added thogether into an array, i need to split these but that can only do to a variable of type string...

Kryptic_0-1600254583545.png

 

 

Highlighted
Resident Rockstar
Resident Rockstar

Re: Splitting array invalid

@Kryptic  

 

Can you please try the Function below - I have decorated the variable to be of type string()

 

split(string(outputs('Compose')),',')

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Highlighted
Helper I
Helper I

Re: Splitting array invalid

Thanks that got me one step further,  i split it at "/" now using: split(string(variables('Array of file names')),'/')

 

I need 2 more things to solve this puzzle

 

1. When i look at the output i see 3 outsputs, why is that? i just need:

 

file1.zip

file2.zip

 

Kryptic_0-1600260728775.png

 

 

2. For every composed string, (which represents a filename) i want to preform an action.

I want to compare that name to a list of files present in a FTP folder, if the name matches with one of the filenames in the folder, nothing should happen.

 

If theres no match, it means a file is missing and i want a email notification. that that filename is not present in my FTP folder.

 

The flow below doesn't work but i constructed it to kinda show the goal i'm aiming towards:

Kryptic_1-1600261678289.png

 

 

 

 

Highlighted
Dual Super User III
Dual Super User III

Re: Splitting array invalid

Hi again

In my opinion, Problem#1 is due to the fact you always have a comma at the end of your string, I mean the one you convert into an array by means of split().

So when performing split(), you always get an extra empty element at the end of your array.

IN your first scfeenshot, you have an 'Append to string' inside an 'Apply to each', right?

My suggestion is to remove 'Append to string', move 'Append to array' inside the 'Apply to each', and assign as its input the expression you are currently using on 'Append to string'. This way you create an array, each element a FileName, no commas, no need for split().

Hope this makes sense



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



Highlighted
Resident Rockstar
Resident Rockstar

Re: Splitting array invalid

@Kryptic We can try to use the replace function and replace all the special characters from the string (",[) with an empty string '' but that is going will not end up in a good solution. 

 

I agree with @efialttes  latest comments and I think that will indeed create a much easier and reliable solution.

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Highlighted
Helper I
Helper I

Re: Splitting array invalid

Thank you, that is alot more simple and got me the string i want for each loop. Now the last step to complete this flow:

 

For every file created i now have the name, I then retrieve a list of all files in my output folder. 

For every file created I need to compare the created file name to every file in the retrieved files list (after a minute)

 

If the created file name is also in the list of retrieved file names, everything is fine.

If the created file name is not in the list of retrieved file names, i need a email notification one is missing. 

 

Basically:

use createdfilename1.zip and create some kind of loop

 

compare createdfilename1.zip to retrievedfilename1.zip, if match

goto next (with createdfilename2.zip)

else

compare createdfilename1.zip to retrievedfilename2.zip, if match

goto next (with createdfilename2.zip)

else

compare createdfilename1.zip to retrievedfilename3.zip, if match

goto next (with createdfilename2.zip)

 

if no match found -> email notification and goto next (with createdfilename2.zip)

 

run that untill all createdfilenames are checked

 

Knipsel.PNG

 

 

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors
Users online (6,040)