SFTP file to other server

asifnoor
Kilo Patron

Hi,

We have a requirement where we need to generate a CSV file and upload that file into other server. This is external server for which we might get SFTP access.

I have already generated the file and now i need to push it to the other server.  Does anyone did such type of integration? If yes, would be great if you can share some ideas.

 

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Asifnoor,

you would require mid server for this since direct communication to sftp may not be possible through ServiceNow. Sometimes there are issues that the sftp server blocks the incoming traffic from Mid Server; if you face this issue probably the sftp team would have to allow the incoming traffic from the machine which has the mid server

I would recommend using Export Set functionality for this; the export set allows to generate csv/xls file for particular table based on some condition you want

you can also mention the fields you want in the export set

in the scheduled export there is post export script; use that to trigger the mid server script include 

Steps:

1) setup a mid server

2) when the csv file is generated push that to mid server folder location considering export set is there

3) write mid server script include which would pick up the latest file from that folder location

4) use combination of java and javascript code to push the file to sftp server

these links can help you:

https://community.servicenow.com/community?id=community_blog&sys_id=475eeaaddbd0dbc01dcaf3231f96198a

https://community.servicenow.com/community?id=community_question&sys_id=30480baddb1cdbc01dcaf3231f96...

https://community.servicenow.com/community?id=community_question&sys_id=bd6c07a5db9cdbc01dcaf3231f96...

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

Hi Ankur,

Thanks for the response. Do you know how to read the file from the mid server back to ServiceNow? I am trying to execute the following commands first to check the list of files in the background script.

var probe = SncProbe.get("Command");
probe.setName("cd /Users/me/Desktop && dir");
probe.create("<MID Server Name>");

It is creating a entry in ECC Queue but the state is always showing ready. its not getting processed. I have modified with the right values when i ran the script.

Any pointers on how to execute the script on Mid server and fetch the file back on to SN?

 

Hi,

you can look for this link; it shows how you can execute command line

http://www.john-james-andersen.com/blog/service-now/command-line-execution-with-servicenow-mid-serve...

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

Yes, i was trying the same thing.

Anyways, i created a separate Probe and gave the ECC Queue topic as Command, then it started working.


Any inputs on how to push the file from Midserver to SN?