- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-04-2022 04:30 AM
Hello guys, I want to copy automatically an image that is uploaded as a record-producer-variable to the image table db_image.
The type of the variable is attachment, so the image is stored in the sys_attachment table.
I tried copying the image with a business-rule, and it (almost) worked.
The image is copied to the image table but i can't open / modify the image.
Also the URL to the image does not work.
any ideas???
Thank you very much!
Script
var imageGr = new GlideRecord("db_image");
imageGr.initialize();
imageGr.name = "test.jpeg";
imageGr.image = current.img;
imageGr.format = "JPEG";
imageGr.insert();
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-04-2022 05:31 AM
Hi,
When you add any image into Images manually it also create one record in sys_attachment table, see if the record is created when you copy it using script.
If not then you may need to write image into the attachment table.
This is how it created new image record in attachment when we insert image manually.
Thanks
Anil Lande

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-04-2022 05:31 AM
Hi,
When you add any image into Images manually it also create one record in sys_attachment table, see if the record is created when you copy it using script.
If not then you may need to write image into the attachment table.
This is how it created new image record in attachment when we insert image manually.
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2022 12:21 AM
Thank you for your tip!
The trick was to update the already existing record in sys_attachment. Change table_name to ZZ_YYdb_image and set the table_sys_id to the corresponding image sys_id in the db_image table.