retrieve SFTP data

lokesho
Kilo Explorer

Hi,

How to retrieve the SFTP data into service now..
Any suggestions would be great help!

8 REPLIES 8

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.


lokesho
Kilo Explorer

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.



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.


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();
}