GlidesysAttachment API is copying attachments every time when the record is inserted
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2023 10:53 PM
Hi,
I am trying to copy the attachments from request to incident table. I know we can do it by "GlideSysAttachment.copy" method. But as per the functionality its copying repeatedly everytime. There is alternate way that we can try to delete all attachments and again we can copy those, but we should do in that way. I am trying to copy the latest attachment attached. Can anyone help on this. Because I searched the community, but unable to figure out this to attach only the latest attachment.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2023 11:07 PM
you can just copy the latest file
check this link where solution is shared; enhance it as per your requirement
How to copy attachment from one File attachment field to another table
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2023 09:50 PM
Hi Ankur,
Thanks for the reply. but that is not my requirement. the thing is when the user tries to attach any attachment in the request form, then that attachment has to insert in incident. we have relation between req and inc.
for example:
REQ00001 - text1.txt file has been attached then that file has to attach to INC00001. With GlideSysAttachment.copy API is copying the attachments repeatedly. i tried by deleting the attachments in INC and again re-attaching from REQ which is working. But users will attach some files directly in INC which should not be deleted. the thing is we need to add whatever the user attach in REQ, that has to attach in INC without disturbing other attachments in INC. Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2023 11:12 PM
Hi @aj2403 ,
Please check the response code from Ankur. It has approach to delete attachment first and then copy again.
Prevent duplicate attachments when copying
If above is not helpful then check below article :-
Avoid duplicating attachment - GlideSysAttachment.copy()
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2023 09:52 PM
Hi Gunjan,
Thanks for the reply. but that is not my requirement. the thing is when the user tries to attach any attachment in the request form, then that attachment has to insert in incident. we have relation between req and inc.
for example:
REQ00001 - text1.txt file has been attached then that file has to attach to INC00001. With GlideSysAttachment.copy API is copying the attachments repeatedly. i tried by deleting the attachments in INC and again re-attaching from REQ which is working. But users will attach some files directly in INC which should not be deleted. We need to add whatever the user attach in REQ, that has to attach in INC without disturbing other existing attachments in INC. Thanks