Send attachments to Mid Server
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2017 12:15 AM
Hi All,
How can I send attachments from Service now instance to a folder in mid server
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2018 01:50 AM
Uhm I'm doing this:
var sa = new GlideSysAttachment();
var binData = sa.getBytes(gr); //Get attachment
var encData = GlideStringUtil.base64Encode(binData); //encode attachment
var ftpFilePath = "D:\\Output\\Test\\"; //local path on midserver
var fileName = "test.pdf";
(where gr is a sys_attachment record)
followed by:
var jspr = new JavascriptProbe("Mid server DEV"); // Creates a dynamic probe for the mid server specified in quotes.
//gs.log('Begin create file probe');
jspr.setName('FileToMidServer'); //This is a arbitrary name for the dynamic probe
jspr.setJavascript("var ddr = new AttachmentSender(); res= ddr.execute();"); //this is the script the probe must run. In this case it calls a mid server script include.
jspr.addParameter("targetFileName",fileName);
jspr.addParameter("encodedData",encData);
jspr.addParameter("targetPath",ftpFilePath);
jspr.create();
After which I start a workflow which uses powershell to move the file to the networkfolder I want.
Directly creating the file on a networkdrive with jspr took waaaay too long
I hope this helps 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2018 05:36 AM
Thanks! That sounds like a good strategy. For now I got the script to work finally, but maybe using a workflow and powershell is a smarter way of doing this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2018 06:00 AM
Glad to be of service 🙂
You'll still need to use this to 'download' the attachment though...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2017 05:28 AM
Hi Prabh,
Any update on this?
Can you mark answer as correct, helpful and hit like if you were able to achieve the requirement. This helps in removing this question from unanswered list and helps people to find similar question easily. Thanks in advance.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2018 12:39 AM
Did you manage to fix it, I am stuck at the same step and with the same error?