Inbound Email Records Getting Deleted Automatically After Import few hours
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2025 10:44 AM
Hi Experts,
I have created an Inbound Email Action to insert records into a specific table. The records are imported successfully and are visible initially, but after 1 to 2 hours, they are no longer visible — it appears they are being deleted automatically.
I’ve included the code below for your reference. Could you please review it and suggest how to prevent the records from being deleted?
Thank you.
(function runAction(current, event, email, logger, classifier) {
var importSetTableName = "u_test_case";
var transformMapIDs = "sys_id";
var applicationScope = "Global";
// Create record
current.name = "Test Record";
current.import_set_table_name = importSetTableName;
current.file_retrieval_method = "Attachment";
current.type = "File";
current.format = "Excel";
current.header_row = 1;
current.sheet_number = 1;
current.sys_package.setDisplayValue(applicationScope);
current.sys_scope.setDisplayValue(applicationScope);
var dataSourceID = current.insert();
new global.EmailFileImportUtils().scheduleImport(dataSourceID, transformMapIDs);
})(current, event, email, logger, classifier);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2025 10:58 AM
@rajibosss11 This is because of the default behavior of the Import Set Deleter scheduled job and email cleanup processes.
It is designed to remove processed data from staging tables and delete processed emails from the system to maintain performance and storage efficiency.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2025 11:01 AM
Can you suggest the code to Keep the record permanent ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2025 11:27 AM
Hi @rajibosss11 ,
You can try this code !
(function runAction(current, event, email, logger, classifier) {
var importSetTableName = "u_test_case";
var transformMapIDs = "sys_id";
var applicationScope = "Global";
// Mark email as processed to avoid deletion
current.state = "processed";
current.update();
// Create Data Source record
var ds = new GlideRecord("sys_data_source");
ds.initialize();
ds.name = "Test Record";
ds.import_set_table_name = importSetTableName;
ds.file_retrieval_method = "Attachment";
ds.type = "File";
ds.format = "Excel";
ds.header_row = 1;
ds.sheet_number = 1;
ds.sys_package.setDisplayValue(applicationScope);
ds.sys_scope.setDisplayValue(applicationScope);
var dataSourceID = ds.insert();
// Schedule import
new global.EmailFileImportUtils().scheduleImport(dataSourceID, transformMapIDs);
})(current, event, email, logger, classifier);
This are some check (kindly check )
- Check if "Delete processed emails" is enabled in Email Properties (System Mailboxes > Administration > Email Properties).
- You can disable or adjust the "Delete processed emails" job if needed.
Thanks,
Chandan
Chandan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2025 11:02 AM
Hi @rajibosss11 ,
Ideally this should not happen unless the system is configured in such a way.
Could you please check if any transform map script, BR is doing the same ?
Please mark this response as correct or helpful if it assisted you with your question.
Chandan