how can we get the file name from an SFTP server

mazin690
Tera Contributor

Hi All,

How can we get the file name from an SFTP server,but is should work dynamically....Because the file name changes, their is no way to standarised the naming format. Any Suggestion 

8 REPLIES 8

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

While using data source and fetching the file; you need to give the exact path along with the file name.

if the file name changes dynamically then you cannot fetch it unless you know what pattern it follows during name change

example: on day 1 file is hello_2019-14-03.csv on next day i.e. 15th it is hello_2019-15-03.csv

in this way what you can do is just before when the file is fetched run a schedule job which would update the file name to the newer one as per today's date.

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

Hi Ankur,

 

Thanks for your time, Actually the above, i have already tried, but here as it name changes dynamically ter is no naming standard followed. 

Is their any way that we can fetch the excel sheet cell value..? Because it gonna hva only the file name. or any other approach to get this work

Hi,

What does it mean to fetch excel sheet cell value? if you don't have the filename then how can you access the data.

one approach:

1) create a custom table with following fields: a) Date b) File Name

2) create a scripted rest api and expose the endpoint

3) ask the 3rd party to consume the endpoint and whenever file name is changed they will consume this endpoint and send the file name information in json request

4) in your scripted rest api you can then get this file name and update it in the custom table

5) whenever data source runs just before that query the custom table and ordrByDesc and set limit as 1; you would get the file name and then update the file name

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

will this work even in the multiple domain?