- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2023 04:15 AM
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?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2023 12:31 AM
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.
Output:
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2023 07:27 AM
for that you will have to use Mid Server script include which uses java language + javascript.
fetch the latest file from that sftp folder and return it back to servicenow.
then update it in data source
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2023 05:29 AM
Found a way to make it work without much scripting.
Using SFTP step available in flow, we can get the file name using wild card characters and use the name wherever required.
Thank you all for your inputs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2023 08:27 AM
please share the detailed steps with screenshots so that it helps future readers as well.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2023 12:31 AM
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.
Output:
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2025 10:06 AM
Hi @Ravindra Kaja @Ravindra Kaj @Ankur Bawiskar @Chuck Tomasi @Jeff Hausman @Ravi Gaurav ,
Im stuck with the step of SFTP to fetch file name from my server ,
i have followed the stes which you have suggested , but those seems to be incomplete since im unable the filename from the server .
Please share you screenshots of the full configuration as these are cropped.
please refer my steps and correct these .
STEP1 - INPUTS
STEP 2 - SFTP STEP
STEP 3 - SCRIPT STEP
Step 4 - Outputs
Please refer this and guide me through this process to -
Fetch a file name from an SFTP server and dynamically update a Data Source file path in ServiceNow Flow Designer.
Thanks.