Service Portal - Record Produer

sharvil Sheth1
Kilo Guru

I have a requirement: As soon as user attaches file in out of the box attachment, then data in the file should be stored in a variable which is multi line text.

sharvilSheth1_0-1770966031570.png

 

10 REPLIES 10

Ankur Bawiskar
Tera Patron

@sharvil Sheth1 

you can handle this after record producer is submitted using after insert BR on your target table and then grab the attachment, parse it to get content and store in that variable

(function executeRule(current, previous) {

    var gr = new GlideRecord("sys_attachment");
    gr.addQuery('table_sys_id', current.sys_id);
    gr.query();
    if (gr.next()) {
        var gsa = new GlideSysAttachment();
        var base64 = GlideBase64.encode(gsa.getBytes(gr));
        current.variables.variableName = GlideStringUtil.base64Decode(base64);
        current.update();
    }

})(current, previous);

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader