Sending Incident Attachments to external system using an Action - Proper Approach?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2024 08:41 AM
I'm sending incident information from ServiceNow to our PeopleSoft system through the Oracle PeopleSoft spoke. Thanks to a forum assist yesterday I'm able to send all relevant incident information to our PeopleSoft system where our developers use that information to work on issues that require software builds and changes. I'm successfully sending all necessary incident fields in XML format to PeopleSoft but the next step is to send all attachments to PeopleSoft. (Preferably attachments rather than attachment URLs since this is an outside group of developers.) Do I add a new REST step to the action or is there another method I should be using?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2024 10:57 PM
Did you check there is any OOB spoke action to send attachments?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2024 04:58 AM
Personally I went with an action that created the list of URLs and sent that to the 3rd party. Problem with sending the file itself is that there may be a lot of content types (image, documents, executables(!), etc.). You may though be able to convert the file into Base64 to add to the data.
Here's the code I used (again without sending the attachment)
//incidentsysid is your Incident's SysID
var attachments = [];
var tAttachments =new GlideRecord('sys_attachment');
tAttachments.addQuery('table_sys_id',incidentsysid);
tAttachments.query();
while(tAttachments.next()){
// Here you could convert your file to Base64 and add the result to the object below
attachments.push({
sys_id : tAttachments.sys_id.toString(),
file_name : tAttachments.file_name.toString(),
content_type : tAttachments.content_type.toString(),
sys_created_on : tAttachments.sys_created_on.toString(),
url : 'https://'+gs.getProperty("instance_name")+'.service-now.com/sys_attachment.do?sys_id='+ tAttachments.sys_id,
})
}
//attachments is now an array with all of your attachments
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2024 12:27 PM
I'm still trying to get this working on our side. Did you set up a storage endpoint?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2024 06:13 AM
No, the URL in the JSON object contains the exact URL to download the file. So I expect the other endpoint to come and get it.
However, as I said, you may be able to convert the attachment to Base64 using JavaScript (not my expertise, more a PowerShell guy, in which I did do it), and then instead of -in addition to- the URL you could send the file content in Base64...