- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2023 02:25 AM
Dear all,
I created an action with one input variable:
URL = https://de.wikipedia.org/static/images/project-logos/dewiki.png
I created an output variable:
MyImage = (type) Image
(function execute(inputs, outputs) {
var imageurl = inputs.URL;
var httpClient = new GlideHTTPRequest(imageurl);
httpClient.get();
var httpStatusCode = httpClient.getStatusCode();
if (httpStatusCode === 200) {
var responseBody = httpClient.getResponseBody();
var base64Image = GlideStringUtil.base64Encode(responseBody);
outputs.image2 = base64Image;
} else {
gs.error('Fehler beim Herunterladen des Bildes. HTTP-Statuscode: ' + httpStatusCode);
}
})(inputs, outputs);
The action will be startet in a Flow.
Action: Create Record
Table: db_image
image > Result from action (image2)
name > hardcoded at this moment
I'm not able to get a image to this database.
I need this for parsing some external content to integrate in the internal KnowledgeBase.
So my question > is it a simple stupid error ?
Is an other workarround possible. It should be a script not manuell upload and also not storing the images outside of servicenow.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2023 05:08 PM
Hi, I think that you will find the db_image record references a sys_attachment record, and the actual attachment is stored in sys_attachment (actually stored in chunks in sys_attachment_doc).
So I would suspect you need to upload the file to sys_attachment first and then create a db_image record pointing to sys_attachment.
Example from a PDI
/nav_to.do?uri=db_image.do?sys_id=687fa131eb1301003eadeb29a206fe05
/sys_attachment_list.do?sysparm_query=table_sys_id%3D687fa131eb1301003eadeb29a206fe05&sysparm_view=
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2023 05:08 PM
Hi, I think that you will find the db_image record references a sys_attachment record, and the actual attachment is stored in sys_attachment (actually stored in chunks in sys_attachment_doc).
So I would suspect you need to upload the file to sys_attachment first and then create a db_image record pointing to sys_attachment.
Example from a PDI
/nav_to.do?uri=db_image.do?sys_id=687fa131eb1301003eadeb29a206fe05
/sys_attachment_list.do?sysparm_query=table_sys_id%3D687fa131eb1301003eadeb29a206fe05&sysparm_view=
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2023 05:04 AM
Thanks for your answer, it looks like I'm coming out of a dead end with the info. I let myself be blinded instead of checking the reference via the Table API.