parse json attachment from inbound email and create record

tkrishna29
Giga Guru

Hi,

Our incoming email contains a JSON file as an attachment. We must parse this JSON file and generate a record from its contents. Could you kindly provide some high-level suggestions on how to accomplish this?

 

Thank you,

Krishna

1 REPLY 1

tkrishna29
Giga Guru

I couldn't find a way to utilize inbound email action for this. So, I wrote a BR on sys_email table record insert and coded as below to achieve the result.

   var result;
    var attachment = new GlideSysAttachment();
    var agr = attachment.getAttachments('sys_email', current.sys_id);
    if (agr.next()) {
        if (agr.getValue('file_name') == "dpdSample.json") {
            var attachmentContent = attachment.getContent(agr);
            result = JSON.parse(attachmentContent);
        }
    }