
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2018 11:49 AM
HI,
I'm using a ui action and use current record information to create a new record. The initial form includes an image field and I'd like to copy the image to the new field ...
....
gr.u_new_image_field = current.u_image_field; does not work for image fields .. is there an easy way to do that?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2018 12:57 PM
var ids = GlideSysAttachment.copy('ZZ_YYsc_cat_item','current.sys_id','ZZ_YYsc_cat_item','destinationsys_id');
var gr = new GlideRecord("sys_attachment");
gr.addQuery("sysid", ids);
gr.query();
if (gr.next()) {
gr.setValue('file_name', 'u_icon.jpg');
gr.update();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2018 08:42 AM
Did you check the thread posted by me?
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2018 10:37 AM
yes. I did , but not completely got it.
I managed to add the attachment, but the picture is broken. So something with the content did not work.
I wonder why "db_image" in involved as I did not finder the original picture there ...
Have to dig deeper to get the code from the link u provided.
Strange that there is no OOB solution for this .. so I will add some reusable function to use like copyfieldimage(fieldname, targettable,targetfield) ....
As I'm no developer ... not that easy 😉

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2018 10:59 AM
I found another solution here, which I think is simple. Try this
var ga = new GlideSysAttachment();
var attachments = ga.copy('db_image', yourImageAttachment.sys_id, 'ZZ_YYx_your_table',row.sys_id);
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2018 12:19 PM
Still do not get it.
a) the picture I added to the source table field ... is available in the sys_attachment table - but NOT AVAILABLE in the db_image table ... so I do not see why the table is involved at all ..
b) row.sys_id ... ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2018 12:25 PM
sys attachment table uses filename as field name.
so let's say you want to copy picture from one cat item to another cat item
you will do
GlideSysAttachment.copy('ZZ_YYsc_cat_item','current.sys_id','ZZ_YYsc_cat_item','destinationsys_id');