Expand my Community achievements bar.

SOLVED

File transfer: vars.filenames is undefined

Avatar

Level 6

I'm using a File Transfer activity to load all csv files in SFTP. Docs say all files present on the server will be stored in vars.filenames. Why it says it is undefined? 

 

  1. Listing of files

    To list the files, select the File listing option from the Action field. Configuration of the remote server is the same as for receiving files. For more information, refer to this section.

    The List all files option, available when selecting the File listing action, allows you to store all files present on the server in the event variable vars.filenames wherein the file names are separated by \n characters.

 

There are files in the server:

ogonzalesdiaz_0-1726262675670.pngogonzalesdiaz_1-1726262713381.png

ogonzalesdiaz_0-1726262836370.png

 

 

 

Javascript code:

var filanamesArray = vars.filenames.split('\n');

for (var i = 0; i < filenamesArray.length; i++) {
var filename = filenamesArray[i];
logInfo("file: " + filename);
}

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @god_prophet 

 

Try with var filenamesArray = vars.filename.split('\n');

 

Thanks,

David



David Kangni

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

Hi @god_prophet 

 

Try with var filenamesArray = vars.filename.split('\n');

 

Thanks,

David



David Kangni

Avatar

Employee

@god_prophet In the Server Folder settings of File Transfer activity, you will have to provide the file selection criteria as well to pick up the files you need

 

Try putting /incoming/<your folder path>/IMPORT_FILES/*.csv.gz