articles created from Incident not copying the attachments from Incident to articles
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2023 10:20 AM
Hi
When articles created from Incident not copying the attachments from Incident to articles, why?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2023 11:52 AM
@Rahul Raja Sami wrote:
... why?
Frankly, because the OOB functionality is designed to intentionally NOT do this...and it makes sense.
This is because the attachment on an incident doesn't necessarily have anything to do with the triage or resolution of an incident (in terms of the ITSM process) and is often it is just supplementary material related to a specific case of the incident lifecycle. The knowledge article which is created from an incident *should be* (in theory) related to a general case in the incident lifecycle (not a specific case)...so, since the attachments are usually specific to the incident, but the kb article is general to the lifecycle, this design makes sense. Not to mention the issues with growing databases due to duplicate files as attachments. The ITSM best practice for this (in theory) would be to link the example incident from the KB article and reference the attachment on that example incident as relevant to the article contents...or manually add the attachment, if/when needed. If the OOB functionality was designed to actually do this (copy attachments), there would be many customers who want that turned off.
.....
To (potentially) be more helpful with this, it seems like you have a use case where you would like this type of custom feature.
The OOB BR which controls these actions is "Incident Create Knowledge" and I'm sure you can modify that appropriately, to also include attachments from the incident. Here is some additional resource(s) to help:
ServiceNow Developers - Business Rules
Understanding Attachments in ServiceNow - ServiceNow Developer Pro-Tips (snprotips.com)
snprotips.com wrote:
Copying/Moving an AttachmentCopying all of the attachments associated with a given record is fairly straightforward. You simply call the copy method of the nearly-undocumented GlideSysAttachment class, and pass in four strings:
The table you want to copy the attachment from (incident, change_request, etc.).
The sys_ID of the record you want to copy the attachment from.
The table that you want to copy the attachment to.
The sys_ID of the record you want to copy the attachment to.
This might look something like this:
var donorTable = 'incident'; var donorID = '2b6644b15f1021001c9b2572f2b47763'; var recipientTable = 'incident'; var recipientID = '78e47fe94f31d200bf004a318110c7d4'; GlideSysAttachment.copy(donorTable, donorID, recipientTable, recipientID);Again however, you might notice that we haven't actually told GlideSysAttachment which attachment we want it to copy over. In this case, that just means that it'll copy over all of the attachments associated with the record we've chosen.
Unfortunately, there doesn't appear to be a built-in way to copy one specific attachment associated with a record, when you have multiple.