- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2022 08:57 AM
Hi, i have a requirement where user needs to attach one document(pdf) on multiple tasks like around 100 incidents.
could anyone please help me!
thanks,
sry
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2022 01:44 PM
Hello sry,
So, me recommendation is simple:
- From those 100 incidents, manually attach the file to one of them
- Go to the sys_attachment table, locate the file that you added, by filtering records where:
- table name = incident
- table sys id = your incident sys_id
- Create a fix script with the following code:
var orig_incident_id = "<sys_id of the incident where you added the attachment>"; copyAtt(orig_incident_id); function copyAtt(orig_incident_id){ var gr = new GlideRecord("incident"); gr.addEncodedQuery("<add your query to pick the other 99 incidents"); gr.query(); var counter = 0; while(gr.next()){ new GlideSysAttachment().copy("incident", orig_incident_id, "incident", gr.sys_id); ++counter; } gs.info("copied attachment to " + counter.toString() + " records"); }​
This should do the trick!!
Please, if this answer is relevant for you, please mark it as correct and helpful.
Thanks,
Filipe

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2022 09:05 AM
Hello,
May I ask what kind of attachment needs to be added to 100 incidents?
As a possible idea: does it make sense to create a knowledge article that will contain that attachment and then do a bulk update to relate the knowledge article to the attachment?
Remember that in this way you are not generating 100 copies of the same file!
Let me know more about this!
Please, if this answer is relevant for you, please mark it as correct and helpful.
Thanks,
Filipe
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2022 09:20 AM
Hi Filipe, thank you for prompt response.
i understand we are duplicating but the user insists he wants to attach same document on all defects.
i have considered KB route but they refused that route.
Thanks,
sry

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2022 10:23 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2022 10:43 AM
Hi Felipe, this is a one time action i think. but i think if we have a solution we can use it for daily right!
thanks,
sry