retrieve SFTP data
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2013 11:48 AM
Hi,
How to retrieve the SFTP data into service now..
Any suggestions would be great help!
- Labels:
-
Integrations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2013 08:01 AM
I know what other customers have done in this situation is they have a script on their side that renames the previous file to something and then always saves the file on the FTP server as the same name so they don't run into this. That would be more consistent.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2013 09:29 AM
Thanks for the update Jason!!
I will get the renamed files only from the SFTP.
but in my datasource I have the field named "file path" that needs to updated (example: CWY_EMP_20130806.csv) Otherwise every time I have to rename the filepath in datasource.
I have to automate this. So I have wrote above script but no luck.
Please see the attached screenshot.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2013 02:37 PM
Maybe I wasn't clear how I explained it. What other customers do is that path and file name are always the same. They have their own script that renames the file to something then copies the new one to the FTP server with the name your path is expecting. That way you don't have to code anything on the ServiceNow side. It is always going to be the same path and file name. But the file does change on the FTP server.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2022 12:23 PM
I derived this from another developers code, hope it helps...
var str = gs.daysAgo(0).replace( /-/g, "" );
var today = str.substring(2,8);
var path = "/SAP/CC_ServiceNow_"+today+"_1702.CSV";
var grd = new GlideRecord('sys_data_source');
grd.addQuery('sys_id', '3748480e1be09910ac1cfe6e034bcb03');
grd.query();
while(grd.next()){
grd.file_path = path;
grd.update();
}