SFTP Data Source with a changing filename

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2016 09:06 AM
I have setup a Data Source that is pulling files from an SFTP server as the source. The system that places the file appends numbers to the end of each exported file so the name of the file changes each day.
The file path that works is /my_inboxes/venafi/Manged Non-F5 Certificates 161108-1100.CSV
The numbers at the end of the file change with each export.
Is there a way in the file path to use a wild card or to just pickup all the files in the directory.
Troy Holmes
- Labels:
-
Integrations

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2016 11:34 AM
Write this script in Scheduled job pre-script. It will change the file name of data source before querying SFTP server.
var str = gs.daysAgo(0).replace( /-/g, "" );
var today = str.substring(2,8);
var path = "/my_inboxes/venafi/Manged Non-F5 Certificates "+today+"-1100.CSV";
var grd = new GlideRecord('sys_data_source');
grd.addQuery('sys_id', 'sys_id of your data source');
grd.query();
while(grd.next()){
grd.file_path = path;
grd.update();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-11-2016 11:10 AM
Deepak this is great. The one issue is the file time on the end may change slightly. What would happen if they generate the file at 1101 instead of 1100 is there a way to compensate for that issue.
Troy

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-11-2016 07:19 PM
It is hard to set name for the time. there would be always some difference is time when they put data. if they can remove it then it is better.
if there is any pattern in change then you can make it dynamic.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2017 06:23 AM
Hi,
I have similar requirement and solution proposed by Deepak helped me to some extent. Can we use any wildcards or like name "starts with"
I tried but of no use. Any suggestions please.
Thanks,
Kiran