how to download Attachment from the incident ticket using Servicenow Orchestration

satiz
Giga Contributor

I need to download the Attachment from Incident Ticket when the Ticket is create and do some excel manipulation in that file

26 REPLIES 26

Julian Hoch
ServiceNow Employee
ServiceNow Employee

Where do you want to download the file to? A client (via browser), or to a Server in the customer infrastructure?


If it's that latter, what I've done in the past is create a custom activity (JDBC-Probe) that sends the file to the MID Server. There you can then do some manipulation, probably using some PowerShell scripts, and send it back.


Hi Julian,



As you mention i have trying to download the attachment using Vb Script i and passing the URL and downloading the file , But   while execute that VB script Manual i am able to execute and i am able to download the file, But While i am trigger the vb,script by Servicenow Using powershell, I am not able to download, In that VB Script i am fetch file using REST API from Attachment table ,



When Executing the VB Script by double click i am able to download but from Service now orchestration it was not working . I was triggering the error message as MSXML3 is not locate


Hi Julian,



Is it possbile to take how you have done   custom activity (JDBC-Probe) that sends the file to the MID Server. That will be helpful for me


Julian Hoch
ServiceNow Employee
ServiceNow Employee

I haven't done any Excel manipulation on the Server but to download the file to the MID-Server I used the following activity that pushes the file to the MID server that I included in the Workflows:



2016-08-11_09-06-21.png




The actual script is in a MID Server Script Include:


var DownloadFile = Class.create();




DownloadFile.prototype = {



  initialize: function () {


  var fc = probe.getParameter("fileContent");


  this.fileContent = Packages.com.glide.util.StringUtil.base64Decode(fc);


  this.fileName = probe.getParameter("fileName");



  this.execute();


  },



  execute: function() {


  var f = new Packages.java.io.File(this.fileName);


  var out = new Packages.java.io.FileOutputStream(f);



  var str = this.fileContent;


  var s = new Packages.java.lang.String(str);


  var b = s.getBytes();



  out['write(byte[])'](b);


  out.close();


  },



  type: DownloadFile


};



Hope that helps.