How to Sync 'Delete All' Attachment action from Jira to ServiceNow

Lucas1109
Tera Contributor

Hi,

 

Currently I'm facing an issue about sync the attachments from Jira (Jira spoke) to ServiceNow through integrationHub the problem occur when execute 'Delete All' attachments from Jira, ServiceNow received payloads of issue update and change log but just only delete one attachment due to change log payload and not able to delete all attachments,Can anyone help me with this?

1 ACCEPTED SOLUTION

Amit Gujarathi
Giga Sage
Giga Sage

HI @Lucas1109 ,
I trust you are doing great.

To troubleshoot this issue, we'll need to examine the integration flow and the code that handles the attachment deletion process. Here's a general approach you can follow:

  1. Review the IntegrationHub flow: Check the flow design and configuration in IntegrationHub to ensure that the correct API calls are being made to Jira for deleting attachments. Confirm that the flow is correctly configured to handle multiple attachments deletion.

  2. Inspect the payload received by ServiceNow: Analyze the payload received from Jira when the 'Delete All' operation is executed. Verify that the payload contains information about all the attachments to be deleted. If necessary, you may need to modify the integration flow to capture and process all attachment data correctly.

  3. Examine the code handling the attachment deletion: Review the script or code responsible for deleting attachments in ServiceNow. Ensure that it is correctly configured to iterate over all the attachments in the payload and delete them individually. If needed, make adjustments to the code to handle multiple attachment deletions properly.

// Assuming you have the attachment sys_id stored in the variable 'attachmentSysId'

var grAttachment = new GlideRecord('sys_attachment');
if (grAttachment.get(attachmentSysId)) {
  grAttachment.deleteRecord();
  gs.info('Attachment deleted successfully');
} else {
  gs.error('Unable to find attachment with sys_id: ' + attachmentSysId);
}

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi



View solution in original post

3 REPLIES 3

Amit Gujarathi
Giga Sage
Giga Sage

HI @Lucas1109 ,
I trust you are doing great.

To troubleshoot this issue, we'll need to examine the integration flow and the code that handles the attachment deletion process. Here's a general approach you can follow:

  1. Review the IntegrationHub flow: Check the flow design and configuration in IntegrationHub to ensure that the correct API calls are being made to Jira for deleting attachments. Confirm that the flow is correctly configured to handle multiple attachments deletion.

  2. Inspect the payload received by ServiceNow: Analyze the payload received from Jira when the 'Delete All' operation is executed. Verify that the payload contains information about all the attachments to be deleted. If necessary, you may need to modify the integration flow to capture and process all attachment data correctly.

  3. Examine the code handling the attachment deletion: Review the script or code responsible for deleting attachments in ServiceNow. Ensure that it is correctly configured to iterate over all the attachments in the payload and delete them individually. If needed, make adjustments to the code to handle multiple attachment deletions properly.

// Assuming you have the attachment sys_id stored in the variable 'attachmentSysId'

var grAttachment = new GlideRecord('sys_attachment');
if (grAttachment.get(attachmentSysId)) {
  grAttachment.deleteRecord();
  gs.info('Attachment deleted successfully');
} else {
  gs.error('Unable to find attachment with sys_id: ' + attachmentSysId);
}

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi



Mathieu Lepoutr
Mega Guru

Hi Lucas

 

Although ServiceNow receives payloads of issue updates and change logs, only one attachment is deleted instead of all attachments. In a similar use-case, I have successfully resolved attachment synchronization challenges using Exalate. You can establish a seamless and robust synchronization between Jira and ServiceNow, ensuring accurate transfer of attachments. Have a look 🙂 

Thanks @Mathieu Lepoutr but I don't want to use 3rd-party.