How to pull file using SFTP data source with dynamic filename

Ravindra Kaja
Tera Expert

Client is placing file on SFTP server everyday with filename appending with date and time. Ex: name-2023-03-14-15-03-52.csv.

 

I tried the filename using wild card character like "name-2023-03-14*.csv" but its not working. Is there a way to get the file having timestamp appended at the end?

 

 

1 ACCEPTED SOLUTION

Below are the steps:

In the SFTP step available OOB (requires Integration Hub subscription), using Get File List command we can pass source path and get the file names present in that folder. This command also accept filenames with wild card character to get specific files. In our case, filename appends with timestamp at the end. So we passed filename as “<filename>_*.csv” and retrieved complete filename shown below.

 

RavindraKaja_0-1681369947371.png

 

Output:

 

 

RavindraKaja_2-1681371021801.png

 

Using script, we can read the filename and pass it over to the SFTP data source which pulls data from the server.

 

Other commands like Copy Files To This Instance are also available which will reduce multiple SFTP calls to the server.

 

PS: To make this work, you should allow connection between mid server and SFTP server.

View solution in original post

10 REPLIES 10

Vasantharajan N
Giga Sage
Giga Sage

@Ravindra Kaja - This requirement is already discussed in another post. Please refer to the link below,

https://www.servicenow.com/community/itsm-forum/dynamically-change-the-import-file-name-from-a-sftp-...


Thanks & Regards,
Vasanth

In that post, it was discussed only about date part. I can append date part but here client is appending timestamp also. As we cant append timestamp, checking the possible ways how to pass the filename.

Ankur Bawiskar
Tera Patron
Tera Patron

@Ravindra Kaja 

you can make it work only when client doesn't add time.

with only current date you can achieve.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Ok. Is there a way to get the filename from the sftp server folder and pass that into the data source?