- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2020 02:07 AM
Dear community,
We're doing some preparation to transition from calls to interactions and currently we have one challenge: it's about transferring original attached files in interactions to new requests or incidents.
So far we can use the standard UI Action "Create Request" to link interactions with new requests and it works as expected and creates a link between current interaction and new request but in case attached files were included in the original interaction, those are not included in the new request.
I've done some research and seems that including in the script something like following line should work:
GlideSysAttachment.copy('sourcetable','sys_id','destinationtable','sys_id');
But in my case, I'm missing the sys_id of the destination record. I'm not sure if that's my only issue but the point is that right now it's not working:
Would anyone have any advice to solve our issue? Same issue is applicable to "Create Incident" standard UI action.
Thank you in advance!
Joaquín
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2020 08:04 AM
Hi all,
I've contacted ServiceNow about this and they've mentioned that it works as expected as it's not the intention of interactions to transfer attached files to related records. My opinion is that from a fulfiller point of view it's not nice having to go back to the original interaction in case you want to check any original attached file.
Having said this, finally I've managed to solve this by creating a business rule on interaction_related_record table after the insert. Here the code I've added:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
if (current.document_table == 'incident'){
var inc = new GlideRecord('incident');
inc.addQuery('sys_id',current.document_id);
inc.query();
if (inc.next()){
GlideSysAttachment.copy('interaction', current.interaction, 'incident', inc.sys_id);
}
}
else if (current.document_table == 'sc_request'){
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('request',current.document_id);
ritm.query();
if (ritm.next()){
GlideSysAttachment.copy('interaction', current.interaction, 'sc_req_item', ritm.sys_id);
}
}
})(current, previous);
I've tested this and works as expected for both incidents and service requests from Agent Workspace.
Additionally there's already an idea in the idea portal asking for this functionality to ServiceNow.
The idea is called "Agent Workspace - copy attachments from Interaction to Incident". I hope everyone interested on this implementation can support it and subscribe to it to be up to date.
Hope it helps!
Joaquín

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2023 12:37 PM
I tried to test this in my PDI which is on Vancouver, and the attachments did not copy.
I checked the property and the incident table was in there.
Has anyone else seen this in Vancouver?
Thanks,
Shannon

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2023 04:46 PM
Hey,
That system property doesn't actually do anything. I had a ServiceNow support call and mentioned that the system property doesn't work.
The UI 'create incident' ui action has the code to copy attachments.
Some instances have an older version of the UI action owned by legacy ITSM workspace app, so it doesn't get updated.
The code should look like this:
var canCreateIncident = false;
if ((current.isNewRecord() && current.canCreate()) || (!current.isNewRecord() && current.canWrite()))
canCreateIncident = current.update();
else
canCreateIncident = true;
if (canCreateIncident) {
var inc = new GlideRecord("incident");
inc.initialize();
inc.caller_id = current.opened_for;
inc.short_description = current.short_description;
if (gs.getProperty("com.snc.incident.create_from_interaction.save") === 'true') {
inc.work_notes = gs.getMessage('Incident created from Interaction {0}', current.number);
var incSysId = inc.insert();
if (incSysId) {
var interactionRelatedGR = new GlideRecord("interaction_related_record");
interactionRelatedGR.initialize();
interactionRelatedGR.interaction = current.sys_id;
interactionRelatedGR.document_table = 'incident';
interactionRelatedGR.document_id = incSysId;
interactionRelatedGR.insert();
}
}
action.openGlideRecord(inc);
new InteractionRelationshipUtil().copyAttachments(current, inc);
}
The last line is what you need
new InteractionRelationshipUtil().copyAttachments(current, inc);
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2023 05:37 AM
OK thanks, I'll try that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2020 06:45 AM
I tried below and it worked for me.. we can add inc.insert() before copying attachments,worknotes and additional comments in UI action script itself.
if(current.update()){
var inc = new GlideRecord("incident");
inc.initialize();
inc.caller_id = current.opened_for;
inc.short_description = current.short_description;
---New lines, need to insert record once needed fields are copied and then work on work notes and file attachments----
//record inserted to incident table
inc.insert();
//copying worknotes and additional comments from IMS to INC
inc.work_notes = current.work_notes.getJournalEntry(-1);
inc.comments = current.u_additional_comment.getJournalEntry(-1);
//copying attachments from IMS to INC
GlideSysAttachment.copy('interaction', current.sys_id, 'incident', inc.sys_id);
inc.update();
action.openGlideRecord(inc);
current.state = 'closed_complete';
current.active == false;
current.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2021 12:50 PM
Don't do this. It will cause issues with the task not showing up in the Related Task related list.
See KB0852997