Inserting a picture to an Image field through Script

mp31
Tera Contributor

I want to insert an image from a script into the table. Basically, I'm receiving an image in the base64 format through a rest API call in my script and now I want to insert the same into the table having a column image of type image.

6 REPLIES 6

You can chekc and modify the below code as per your requirement

var
content =current.variables.base64value; //base64value is my Multi line text variable name
//gs.addInfoMessage(content);
var fileName = 'u_sign_image:submitter-sign.png'; //u_sign_image is a image type field name

var contentType = 'image/png';
var tableName = 'sn_hr_core_case_total_rewards';
var tableSysId = current.sys_id;
var eccGr = new GlideRecord('ecc_queue');
eccGr.initialize();
eccGr.setValue('agent', 'AttachmentCreator');
eccGr.setValue('topic', 'AttachmentCreator');
eccGr.setValue('name', fileName + ':' + contentType);
eccGr.setValue('source', tableName + ':' + tableSysId);
eccGr.setValue('payload', content);
var sys_id = eccGr.insert();

Check the above comment, editing this as I commented the same thing twice.