parse json attachment from inbound email and create record
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2023 06:10 AM
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
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2023 10:26 AM
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);
}
}