Is it possible to insert the image registered in the UI page into the column type image?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2023 12:01 AM - edited 11-24-2023 12:20 AM
String values in the UI Page can be inserted by putting the value as is in setValue.
ex) gr.setvalue(~~,~~) -> gr.insert()
But I don't know how to insert an image.
Implement to insert an Image in the UI Page as shown in the picture below.
Is it possible to insert into a column whose type is 'Image'?
Also, is it possible to save the image as an image type and load it from the UI PAGE to show the image?
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2023 06:56 PM
Yes it can. It's actually not an insert in the table column but save as an attachment file with the columns of the attachment as the following:
file_name: "picture"
table_name: "ZZ_YY" + the name of the table where the image should display for the image type field
table_sys_id: the sys_id of the record on the table where the image should display for the image type field
And then for the image to display on the record that has the the image field insert the sys_id of the attachment as the value.
You can see this set up if you take a look at one of the cmdb_hardware_product_model records for a cmdb_ci record.
Below I use the Apple Macbook Pro 15" as the example.
You can see that the "Picture" field has a value of a sys_id. This is a sys_id of an attachment. If you take that sys_id and navigate to the attachment table and filter on the sys_id you'll see the attachment. Then in the "Table Sys Id" column you'll see that the sys_id value matches the sys_id of the cmdb_hardware_product_model where that image displays.
In conclusion:
1) Save the uploaded image as an attachment
2) When saving as an attachment ensure you populate the fields listed below
a) File name ("picture")
b) Content type ( the MIME type of the file; ie. image/png, image/jpg, image/tiff etc)
c) Table name (prepend with ZZ_YY the appropriate table name)
d) Table Sys ID (The sys_id of the appropriate record where image should display)
3) Take the sys_id of the attachment and save as the value for the "Picture" field on the appropriate record