Send report s an attachment to sftp server

sreekeerthi
Tera Contributor

Hi,

 

We have a requirement to send report as an attachment to SFTP server. for this, I have created a table and a scheduled script to generate csv file of the report everyday and attach it to the table. I have created the credentials and also connections alias. But struck with the flow on how to send this over SFTP. Can anyone please help on this request.

 

Thank you in Advance!

 

Regards,

Sree Keerthi Kasula

2 ACCEPTED SOLUTIONS

Bhimashankar H
Mega Sage

Hi @sreekeerthi ,

 

There are several ways to send files from ServiceNow to an SFTP server:

  • IntegrationHub SFTP Spoke (preferred, if available—requires licensing)

  • MID Server SFTP Script/Command (uses MID server for SFTP execution)

  • Legacy Orchestration SFTP Activities (older, but still in some enterprises)

Refer the below overview for each type.

1. Using Integration Hub Spoke

  • Install SFTP spoke.
  • Crate a flow with appropriate trigger condition
  • For action retrieve sys_id for attachment then use 'Copy Attachments to SFTP Server' action by providing the the SFTP connection alias, the target directory/file name on the SFTP server, and the attachment.

 

2. Using Mid Server Custom Script

  • Set up MID server in your network environment.
  • Export the file to the MID Server's local file system using Export Sets.
  • Use a Script step (within Flow Designer or Orchestration) or PowerShell/Unix script on the MID Server to execute the SFTP PUT command and transfer the file

 

3. Orchestration SFTP Activities

  • Use the SFTP File Transfer activity pack to configure and automate the transfer via a ServiceNow Workflow.
  • Set up SSH/SFTP credentials.
  • Use the "SFTP Put File" activity in the workflow, referencing your attachment.

 

For more detail information, please refer the below references.

Outbound SFTP Integration ,  Pass File from Servicenow to SFTP , Put .csv file from MID server to SFTP , SFTP File Transfer Workflow Steps 

 

Thanks,
Bhimashankar H

 

-------------------------------------------------------------------------------------------------
If my response points you in the right directions, please consider marking it as 'Helpful' & 'Correct'. Thanks!

View solution in original post

@sreekeerthi 

Thank you for marking my response as helpful.

As per new community feature you can mark multiple responses as correct.

If my response helped please mark it correct as well so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

7 REPLIES 7

Amarnadh
Tera Contributor

Hi Keerthi,

You can Use Export sets and mid server to send the file. You have to create Export Definition and Target in Export sets. 

Then you need to write a power shell script to move the file to sftp server 

Bhimashankar H
Mega Sage

Hi @sreekeerthi ,

 

There are several ways to send files from ServiceNow to an SFTP server:

  • IntegrationHub SFTP Spoke (preferred, if available—requires licensing)

  • MID Server SFTP Script/Command (uses MID server for SFTP execution)

  • Legacy Orchestration SFTP Activities (older, but still in some enterprises)

Refer the below overview for each type.

1. Using Integration Hub Spoke

  • Install SFTP spoke.
  • Crate a flow with appropriate trigger condition
  • For action retrieve sys_id for attachment then use 'Copy Attachments to SFTP Server' action by providing the the SFTP connection alias, the target directory/file name on the SFTP server, and the attachment.

 

2. Using Mid Server Custom Script

  • Set up MID server in your network environment.
  • Export the file to the MID Server's local file system using Export Sets.
  • Use a Script step (within Flow Designer or Orchestration) or PowerShell/Unix script on the MID Server to execute the SFTP PUT command and transfer the file

 

3. Orchestration SFTP Activities

  • Use the SFTP File Transfer activity pack to configure and automate the transfer via a ServiceNow Workflow.
  • Set up SSH/SFTP credentials.
  • Use the "SFTP Put File" activity in the workflow, referencing your attachment.

 

For more detail information, please refer the below references.

Outbound SFTP Integration ,  Pass File from Servicenow to SFTP , Put .csv file from MID server to SFTP , SFTP File Transfer Workflow Steps 

 

Thanks,
Bhimashankar H

 

-------------------------------------------------------------------------------------------------
If my response points you in the right directions, please consider marking it as 'Helpful' & 'Correct'. Thanks!

Abhay Kumar1
Giga Sage

@sreekeerthi There are few ways to achieve this.

Either create a powershell script running at specific time to move file 

Or have a batch job on server itself to be running through window scheduler 

Or through destination side to have copied file first before doing any sort of operation.

Hope this will help

 

Ankur Bawiskar
Tera Patron
Tera Patron

@sreekeerthi 

you can export that file to mid server and then write a powershell script to move it from Windows mid server to SFTP

Another way is to write mid server script include and push it to SFTP, check this and enhance

Send an Attachment from Service Now and store it on FTP server via MID server

there is also SFTP workflow but not sure if it's free or paid

SFTP File Transfer workflow 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader