josh_nerius
ServiceNow Employee

Hello,



The example code you're using never specifies which Request Item to attach this file to.



Try something like this:


var base64String = "...."


var attachment = new GlideSysAttachment();


var gr = new GlideRecord("sc_req_item");


gr.get('aeed229047801200e0ef563dbb9a71c2'); // Replace this with desired sys_id


// find the corresponding record


var attachment_sys_id = attachment.writeBase64(gr, "test.pdf", "application/pdf", base64String );


gs.log("system attachment id:" + attachment_sys_id);



Replace the sys_id with the sys_id of the record you want to add this attachment to.