how to pass file from ServiceNow to sftp

jobin1
Tera Expert

Hi All,

 

We have a requirement to send files from ServiceNow to Sftp, how we can achieve this? Are there any plugins or out-of-the-box options available for this?

14 REPLIES 14

Amit Gujarathi
Giga Sage
Giga Sage

Hi @jobin1 ,
I trust you are doing fine.

 

To send files from ServiceNow to SFTP, you can use the "SFTP Sender" plugin available in the ServiceNow store. This plugin provides an out-of-the-box solution for sending files from ServiceNow to an SFTP server.

Here's how you can use the SFTP Sender plugin to send files to SFTP:

  1. Install the SFTP Sender plugin from the ServiceNow store.
  2. Create a script that retrieves the file you want to send to SFTP. Here's an example of how you can retrieve a file:

 

var file = new GlideRecord('sys_attachment');
file.addQuery('table_name', 'incident');
file.addQuery('table_sys_id', 'incident_sys_id');
file.addQuery('file_name', 'file_name');
file.query();

if (file.next()) {
  var fileContent = file.getValue('content');
  var fileName = file.getValue('file_name');
}

 

Replace "incident_sys_id" with the sys_id of the incident record that contains the attachment you want to send. Replace "file_name" with the name of the file you want to send.

  1. Use the SFTP Sender plugin to send the file to SFTP. Here's an example of how you can use the plugin:

 

var sftpSender = new SFTPSender();
sftpSender.setServer('sftp_server_name');
sftpSender.setPort('sftp_server_port');
sftpSender.setUsername('sftp_username');
sftpSender.setPassword('sftp_password');
sftpSender.setRemotePath('sftp_remote_path');
sftpSender.setLocalFile(fileContent, fileName);
sftpSender.upload();

 

 


Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi



Thanks for the update Amit,
I was checking for the plugin but it's not available for me in-store, can u share the link or a sample image of the plugin?

jobin1_0-1683039738424.png

 

Mike_R
Kilo Patron
Kilo Patron

Hi Mike,
Is there any other way for achieving this? without using any plugins and mid servers? 
Regards,

Jobin