Copy Attachments from attachment variable in RITM to Catalog item form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2022 03:47 AM
Hi,
Here I'm stuck with an issue, that I want copy Attachment from Attachment variable in RITM table to Catalog item form using UI Action. I have tried with this script and I'm not getting any output.
GlideSysAttachment.copy('ZZ_YYsc_req_item',sourceSYSID','sc_cat_item',sys_id=targetSYSID');
var count = 0;
var gsa = new GlideSysAttachment();
var att = new GlideRecord('sys_attachment');
att.addQuery('table_name', 'ZZ_YYsc_req_item');
att.addQuery("table_sys_id", current.sys_id);
att.query();
When I click the refill button it should redirect to the catalog item and the Attachment which stored in attachment variable should paste in the catalog item form
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2022 03:53 AM
Hi,
I shared solution for this 2years ago
Disable ZZ_YY prefix from attachment when added through record producer
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
08-18-2022 12:25 AM
hi,
Thanks for your reply,
I have tried with UI action but it's not working properly. I have attached the image extra clarification. how can I exactly copy attachment from attachment variable to service catalog by clicking refill button ?
can you help me with code!
thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2022 12:36 AM
Hi,
I already shared link where I provided solution for what you asked i.e. how to copy file attached to attachment variable to target record
What's not working?
Can you share what script did you tried?
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
08-18-2022 03:17 AM
Hi
I have tried with this script. When I'm using this script it's not redirecting to the catalog item. if I click UI action it takes me to the previous page.
var attachment = new global.GlideQuery('sys_attachment')
.where('table_sys_id', current.sys_id)
.where('file_name', current.<field_name>.getDisplayValue())
.selectOne('table_sys_id')
.get();
new global.VariableUtil().copyAttachment(attachment.sys_id, 'sys_data_source', dataSourceID);