- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2021 11:43 PM
Hi All,
I want to copy attachment from File attachment field created on incident table to same record so it will show in manage attachment at the top of the record, can you please help.
I tried GlideSysAttachment.copy function but it didn't work.
Thanks,
Pritam
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2021 12:31 AM
Hi,
please update the script as this
(function executeRule(current, previous /*null when async*/) {
// Add your code here
GlideSysAttachment.copy('ZZ_YY' + current.getTableName(), current.sys_id, current.getTableName(), current.sys_id);
// rename the table_name
var gr = new GlideRecord("sys_attachment");
gr.orderByDesc('sys_created_on');
gr.addQuery("table_sys_id", current.sys_id);
gr.setLimit(1);
gr.query();
if (gr.next()) {
gr.table_name = current.getTableName();
gr.update();
}
})(current, previous);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2021 03:52 PM
This is not working, the problem is that ServiceNow appends 'ZZ_YY' before target table name by default.
For example, if we write:
GlideSysAttachment.copy('ZZ_YYx_my_source_table', source_sys_id, 'u_target_table', target_sys_id);
Then in sys_attachment, the target table name is 'ZZ_YYu_target_table' and not 'u_target_table'.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2025 08:54 AM
How can i copy from specific fields if it file attachment field more than 1.
Please appreciate the efforts of community contributors by marking the appropriate response as the correct answer and helpful. This may help other community users to follow the correct solution in the future.
********************************************************************************************************
Cheers,
Prashant Kumar
ServiceNow Technical Architect
Community Profile LinkedIn YouTube Medium TopMate
********************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2022 11:40 AM
Thank you!
I didn't know where attachments were stored using attachment fields. My error was that I tried directly with the pure table and I needed to add ZZ_YY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2021 12:17 AM
Hi Ankur,
Thanks for quick reply, but it is not working.
Best Regards,
Pritam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2022 03:27 AM
Hello Pritam. I have a similar requirement. And this script isn't working for me. It will be great if you could tell me how you did it.