How to export excel file from ‘sys_attachent’ table to midserver
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi everyone
I have requirement to export excel file from ‘sys_attachment’ table from servicenow to midserver file path location. I need variable information also so ‘export sets’ feature won’t help me in this case.
so something like flow designer with custom script am looking for. Can anyone please how to achieve this ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi Buddy,
At a high level, the reason this feels hard is because ServiceNow cannot directly write files to a MID Server’s filesystem. Anything that ends up on the MID has to be executed by the MID itself not by the instance.
So the pattern is:
Flow runs on the instance → instance sends the file to the MID → MID writes it locally
Since Export Sets won’t work for you (because you need variables), the clean approach is a Flow + custom server-side script + MID execution.
In simple terms:
Flow triggers (manual, scheduled, or record-based).
A Script step in Flow:
Reads the Excel attachment from sys_attachment
Encodes it (base64)
Sends it to the MID using the ECC queue
The MID Server receives the payload and:
Decodes the file
Writes it to the specified directory on disk
That’s it conceptually.
Key points to keep in mind:
You cannot write directly to D:\ or /opt/… from a Glide script.
The MID must be explicitly told to do the write.
The MID service account must have OS-level write permissions to the folder.
Why Flow Designer works here:
Flow handles the “when” and “which attachment”
The custom script handles “read attachment + send to MID”
The MID script handles “write file locally”
Where your variable data fits:
Include variables in the payload you send to the MID
Either:
add them to the filename, or
write a companion .json file next to the Excel file
If you want this to be simpler and you have IntegrationHub / Orchestration, there may already be a MID-capable “write file” action you can reuse. Without it, the ECC + MID script pattern above is the standard and supported way to do this. I hope this helps 🙂
@satyakumars - Please mark Accepted Solution and Thumbs Up if you found Helpful!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
@Matthew_13 - I appreciate your time. I tried using javascriptprobe and its not supporting. Then tried with below script, flow was successful but ecc queue record shows error as "
