Copy image field from one form field to order record form field via script ...

Zod
Giga Guru

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?

1 ACCEPTED SOLUTION

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();
}

View solution in original post

16 REPLIES 16

Mike Patel
Tera Sage

Images are stored on attachment table so you have to query sys_attachment table to copy it.

... ok. Thank you.

I can find the image on the sys_attachment via the record sys_id and the field name .. , but how to I COPY the image to the new field ... ?! Could you please show me an example scripting for that?! 

Big thnx!

Try GlideSysAttachment.copy('sourcetable','sys_id','destinationtable','sys_id');

this will copy the attachments - but I have a field that is containing the image like sc_cat_item.picture ... 

How to copy the picture from one cat item to an other? Not linking to it but creating a duplicate that then belongs to the other item ...