How to assign Image in db_Image table to an Image field type?

eduzol
Tera Contributor

Hi team,

I just imported images using a zip file attachment into db_image table.

We also have a Images table in our scoped application with an image field and some additional metadata.

Now that I imported the images, how can I assign an imported image to a Image field in my application?

I looked into the Image field documentation : Add an image field   , but found no instructions to do that.

Maybe I can use GlideRecord api?

Please help.

Kind regards.

-

Eduardo

1 ACCEPTED SOLUTION

eduzol
Tera Contributor

Hi Team,



After doing some additional research I found the solution which I will share for the benefit of the community:


How to Copy One image(Field 1) to another image(Field 2) both fields are of Image type



Basically we can use GlideSysAttachment to link an image imported in db_image table to an existing IMage field in any scoped application table.



var ga =   new GlideSysAttachment();


var attachments = ga.copy('db_image', yourImageAttachment.sys_id, 'ZZ_YYx_your_table',row.sys_id);



Thanks


View solution in original post

8 REPLIES 8

Harsh Vardhan
Giga Patron

eg: if i create an field (image type) on incident table then if you will upload the image that will save into incident table.


i think you can query those file and write after business rule to update it in db_image table.


@harsh_vardhan Do you have sample code, as this is binary information and I have no experience with binary information, what is the API call for that?


I did not try. i can have look and will get back to you.



by the way you can refer the link below .



Talk:Scripting of Field Types - ServiceNow Wiki


Hi @harsh_vardhan in the link you provided I can read " There is no API for scripting them, just as with attachments." , however this post is from 2012, 5 years ago, is this affirmation still true? Kindly please advise.