How to overwrite an image field using a script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2022 12:31 AM
I would like to know how to overwrite image fields using a script. I am trying to import a data with an image field and here's where I am at right now.
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// Add your code here
var fileName = source.u_file_name;
var fileContentType = source.u_content_type; // such as image/jpeg or application/pdf
var fileData = source.u_base64_data;
var sa = new GlideSysAttachment();
sa.write(target, fileName, fileContentType, fileData);
})(source, map, log, target);
The script will make it so that it will show up the attached files but I would like to replace/overwrite the image field with the attached file so there would be no need for clicking "Click to add" manually.
- Labels:
-
Problem Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2022 12:37 AM
Hi,
so you need to copy file from the record to the field?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2022 12:39 AM
Hi,
check this
How to take an attachment and put it into an image field
How to copy an attachment to an Image field within the same form?
How to set a default image on an image field (not knowledge)
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2022 12:54 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2022 12:57 AM
Hi,
Did you go through the links I shared above?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader