Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Image from db_image to attach on a particular record

Not applicable

I have an image stored in db_image table.

Now from the work flow, I want to attach it as a attachment to a particular Request.

How can I achieve this?

 

1 ACCEPTED SOLUTION

Mark Roethof
Tera Patron

Hi there,

When adding a new image db_image, note automatically a sys_attachment record is created:

find_real_file.png

Knowing this, with GlideSysAttachment you could copy the attachment record. Use the table_name and table_sys_id of the record you are after. See this docs page about GlideSysAttachment: https://developer.servicenow.com/app.do#!/api_doc?v=newyork&id=r_SGSA-GlideSysAttachment

Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

View solution in original post

5 REPLIES 5

Mark Roethof
Tera Patron

Hi there,

When adding a new image db_image, note automatically a sys_attachment record is created:

find_real_file.png

Knowing this, with GlideSysAttachment you could copy the attachment record. Use the table_name and table_sys_id of the record you are after. See this docs page about GlideSysAttachment: https://developer.servicenow.com/app.do#!/api_doc?v=newyork&id=r_SGSA-GlideSysAttachment

Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Not applicable

Hi,

db_image is a table name. And whenever an image is added to this table, record is not automatically created in sys_attachment table.

Regards,

Sindhuja. 

It is, see the example image posted.

Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Not applicable

Hi Mark,

May be it would add a sys_attachment record if we add the image as attachment in db_image record. But not when we add it using Image field.

Below code worked for me.

var copyAtt = new GlideSysAttachment();
copyAtt.copy('db_image','1fdc9bc13762c850c11716a543990e1f','sc_request',current.request);

Regards,

Sindhuja.