- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2020 09:16 AM
Hi Community,
I have an integration currently in place and have attachments for incidents being sent within a 1 minute expiry when the attachment is on the attachment table for over 1 minute the attachment is not included when the ticket is sent over API.
The above avoids duplication of attachment sending of old attachments, however sometime agents will first attach an attachment to the record, then will complete the ticket, which by the time they have completed the ticket the attachment is over 1 minute and doesn't get sent.
Is there a better way to handle attachment handling? to avoid the duplication of attachments going backwards and forwards with the 3rd party integration?
Many thanks
Steve
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2020 10:01 AM
On the sys_attachment table I have true/false field "Attached"
When we make third party rest call it returns the status code which depicts whether the call was successful or not. Here is the chunk of code that flips the value of Attached. I hope this will give you a rough idea of what is done and direct you in the right direction.
var attachmentRec = new GlideRecord("sys_attachment");
// query to return attachments where Attached is false table name is incident and sys_id is the sys_id of record inserted.
attachmentRec.addEncodedQuery('u_attached=false^table_name=incident^table_sys_id='+SYS_ID_OF_RECORD);
attachmentRec.query();
while (attachmentRec.next()) {
/* REST CALL CODE HERE */
var response = attachmentMessage.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
if (httpStatus.toString() == "201") {
attachmentRec.u_attached = 'true';
attachmentRec.update();
}
}
}
Thanks & Regards,
Sharjeel
Muhammad

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2020 10:01 AM
On the sys_attachment table I have true/false field "Attached"
When we make third party rest call it returns the status code which depicts whether the call was successful or not. Here is the chunk of code that flips the value of Attached. I hope this will give you a rough idea of what is done and direct you in the right direction.
var attachmentRec = new GlideRecord("sys_attachment");
// query to return attachments where Attached is false table name is incident and sys_id is the sys_id of record inserted.
attachmentRec.addEncodedQuery('u_attached=false^table_name=incident^table_sys_id='+SYS_ID_OF_RECORD);
attachmentRec.query();
while (attachmentRec.next()) {
/* REST CALL CODE HERE */
var response = attachmentMessage.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
if (httpStatus.toString() == "201") {
attachmentRec.u_attached = 'true';
attachmentRec.update();
}
}
}
Thanks & Regards,
Sharjeel
Muhammad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2020 11:06 AM
Sharjeel,
Thank you, that's much appreciated, you are highly helpful as usual and its much appreciated.
Thanks
again
Steve

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2020 11:27 AM
Happy to help 🙂
Muhammad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2021 10:50 PM
Hi Sharjeel,
How could i implement the above solution through Flow designer ?