duplicate attachments in activity log
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 01:57 AM
Hi all,
I have created an Attachment field in the record producer, but after I upload the attachment, two records of the same attachment will appear in the ticket page. What is the reason for this? The HR module I use, There is a method in the record producer script: new sn_hr_core.hr_ServicesUtil(current, gs).createCaseFromProducer(producer, cat_item.sys_id);
Is the question related to this method?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2023 03:04 PM
Do you need an "attachments field"? What happens if you just use the out of the box attachments functionality?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi Experts!
I think I saw a correct answer previously but I can't seem to find it, so I'm reproducing it here.
This is expected behaviour according to servicenow KB: Attachment variable on record producer is duplicating attachements when submitting request - Known E...
As a workaround I've implemented a suggestion on the community to delete attachment on the variable that is "map to field". As a variable in a record producer the file is there on the record itself so we can have only one.
On the question_answer table, create a business rule to delete the attachment associated with the variable
Condition:
(current.question.map_to_field && (current.question.type == 33))
Script:
(function executeRule(current, previous /*null when async*/ ) {(function executeRule(current, previous /*null when async*/ ) { var oldAttachSysId = current.value; //delete the attachment var attGR = new GlideRecord('sys_attachment'); attGR.get(oldAttachSysId); attGR.deleteRecord(); })(current, previous);
that successfully deletes the attachment on the variable.
When deleting the attachment we need to remove also the sys_attachment_doc table which has the binary data of the attachment. So I used GlideSysAttachment for that.
So this deletes the complete attachment data (less storage taken then).
Hope this helps someone.
Thank you.
Best!