2 records inserted in Attachment Table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2024 03:25 AM
Hi All,
I am working on Import set API Rest Integration (Using Transform Map)
My ABC (ServiceNow) Instance will receive an attachment file from a third party (ServiceNow) in base64 format and that file needs to be attached to the incident record after decoding from base64 format.
Scenario 1: To achieve this I have created a separate Inbound Import set with Target Table "Sys_Attachment" and created the below fields on the stagging form.
I created a Transform Map with a run script, but the Write() and writeBase64() methods did not work due to limitations in the global scope.
I used the ECC_Queue to insert an attachment record and create it in the Attachment Table, which should link it to the Incident record. While this process worked, it resulted in the creation of two separate records in the Sys_attachment form. Consequently, the Incident form now has two attachments (if I map the file name and Table sys ID)else it will be single on the incident form.
1. The first attachment has empty details because I haven’t mapped any fields from the Attachment table as it will get append on Incident form with 0 bytes file. I’m sending all the necessary fields through the ECC Queue in the script. (This record sysid I can see in response while testing in Postman)
2. The second attachment record contains proper details with all fields mapping and decoded files (refer to the screenshot below) This record Sysid is not coming in Response.
When I do map four fields, those fields are populating instead of empty records, but the resulting attachment has a size of 0 bytes.
If I set the "ignore" parameter to true in the Transform MAP to skip creating empty records, it results in only one record being created from ECC_Queue. However, the API response states, "Response: record is ignored by script," which does not provide me with the sys_id needed for the integration response. Therefore, I'm unable to proceed with this approach.
I have tried creating a Transform map script on Before/ on After but still, this script is creating a separate record on the attachment form.
Please see the below script.
Could you please suggest alternative ways we can achieve this?
Note: I prefer not to create a scoped application for the write() method, as it involves extra work and the need to provide roles, permissions, ACLs, and a scoped application.