Extract XML from E-Mail und create or update incident
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10 hours ago - last edited 10 hours ago
Hello everyone,
I'm looking for a way to automate the extraction of content from an XML file received via E-Mail and use it to create update records in the Incident table.
Manually, I achieved this by setting up the file as a Data Source, then using an Import Set and a Transformation Map to perform the transform.
Is there a way to automate this entire process? I attempted to use Inbound Actions but wasn't successful.
Any guidance or suggestions would be greatly appreciated!
Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
Hi,
You cannot execute a data source directly from script. Instead you can create a scheduled import and this can be created from script. So first step is to create Scheduled import using the below steps:
1) Navigate to System Import Sets > Administration > Scheduled Imports
2) Create a new Record with data source as your data source and Run as Once
3) Note down the sys_id
You need to execute the following in Inbound Action:
1) Delete the attachment in Data Source
2) Copy the attachment from email to Data Source
3) Execute the scheduled import set
Refer the below sample script for reference:
var tableName = "sys_data_source";
var tableSysId = "<sys_id of data source>";
// Remove Attachments
var grAttach = new GlideRecord('sys_attachment');
grAttach.addQuery('table_name', tableName);
grAttach.addQuery('table_sys_id', tableSysId);
grAttach.query();
grAttach.next();
grAttach.deleteMultiple();
// Copy attachment from email
GlideSysAttachment.copy('sys_email', current.sys_id, tableName, tableSysId);
//Execute the scheduled import
var grSchImp = new GlideRecord('scheduled_import_set');
if(grSchImp.get('<sys_id_of_your_scheduled_import>')){
SncTriggerSynchronizer.executeNow(grSchImp);
}
Palani
