- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2020 08:20 AM
Hello,
I have a UI action that creates a new record in a new table, it then copies all of the old info and inputs it into the new record. However, I would like the attachments to transfer as well. How can I achieve this?
Here is what I have so far:
var gr = new GlideRecord('x_utsll_candidate_candidate_tracking');
gr.first_name = current.first_name;
gr.email_address = current.email_address;
gr.last_name = current.last_name;
gr.insert();
How can I also transfer the attachments?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2020 09:58 AM
This worked for me:
var gr = new GlideRecord('x_utsll_candidate_candidate_tracking');
gr.first_name = current.first_name;
gr.email_address = current.email_address;
gr.last_name = current.last_name;
var sysID = gr.insert();
GlideSysAttachment.copy('x_utsll_candidate_candidate_outreach', current.sys_id, 'x_utsll_candidate_candidate_tracking', sysID);
var mySysID = current.update();
current.deleteRecord();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2020 09:58 AM
This worked for me:
var gr = new GlideRecord('x_utsll_candidate_candidate_tracking');
gr.first_name = current.first_name;
gr.email_address = current.email_address;
gr.last_name = current.last_name;
var sysID = gr.insert();
GlideSysAttachment.copy('x_utsll_candidate_candidate_outreach', current.sys_id, 'x_utsll_candidate_candidate_tracking', sysID);
var mySysID = current.update();
current.deleteRecord();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2020 08:32 AM
If not interested in keeping your old records:
Already to show you a bit what I'm after:
This is just a random sys_attachment record. You could actually simply update the table name and the sys_id, to your new table and new sys_id. Instantly the attachment is on that new record!
Now only scripted and... testing if this works fine for your ?scoped? app.
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field