Integration - attachment handling

SW7
Giga Guru

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 

1 ACCEPTED SOLUTION

On the sys_attachment table I have true/false field "Attached"

find_real_file.png

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

Regards,
Muhammad

View solution in original post

8 REPLIES 8

vkachineni
Kilo Sage
Kilo Sage

Maintain a custom table with name of integration, task, attachment sys_ids that were sent over. Select the attachments for the incident that are not in the list to send over.

Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Vinod Kumar Kachineni
Community Rising Star 2022

Vkachineni,

Thank you for your advice, however I should have mentioned that I want to avoid having to maintain custom tables on the instance. 

Many thanks

Steve

MrMuhammad
Giga Sage

I am using a custom true/false field on the attachment table which turns to true when attachment successfully sent. I flip the value based on response received from API call and while sending the attachment my script first check whether the value of custom field is true or false. if true, attachment gets ignored. 

 

Thanks & Regards,

Sharjeel

Regards,
Muhammad

Sharjeel,

Thank you so much for the answer, that look like a really good solution, would you be able to share the details of the script needed just for this action and the a screenshot of the attachment table where its configured?

Many thanks

Steve