- 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
01-10-2020 02:28 AM
Might be worth adding g_service_catalog.openCatalogItem to a variable to see if it returns a value, there's no documentation about that method anywhere so not sure how it works.
Can you get the sys id of the interaction from the request item that gets created? It might be easier to set up a before insert rule on the request item if so.
- 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-21-2021 12:37 AM
Hi Joaquin,
Can you please guide how to transfer attached files from interaction to Catalog task? I tried your code but still it is not auto copying the attachments to catalog task
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2023 07:24 AM
Hii @Joaquin Campos @Jyoti Tripathi @Elena Karrer please can you help me out to understand the Code.
Thanks & Regards
Utsav