how to pass file from ServiceNow to sftp
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2023 07:41 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2023 07:56 AM
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:
- Install the SFTP Sender plugin from the ServiceNow store.
- 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.
- 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2023 08:02 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2023 07:57 AM
There's a step for this in flow designer/integration hub
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2023 11:58 PM
Hi Mike,
Is there any other way for achieving this? without using any plugins and mid servers?
Regards,
Jobin