Skip to content

Commit d5e58c8

Browse files
Incident creation from email with attachments handling (#1388)
* Script.js * readme.md
1 parent 17207fe commit d5e58c8

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Email Inbound Action: Create Incident from Email
2+
(function() {
3+
var incidentGR = new GlideRecord('incident');
4+
incidentGR.initialize();
5+
6+
// Set the incident details from the email
7+
incidentGR.short_description = email.subject; // Use email subject as short description
8+
incidentGR.description = email.body; // Use email body as description
9+
incidentGR.caller_id = email.from; // Set caller from the email sender
10+
11+
// Insert the new incident and capture the sys_id
12+
var incidentID = incidentGR.insert();
13+
14+
// Handle attachments
15+
var attachments = email.attachments;
16+
if (attachments) {
17+
for (var i = 0; i < attachments.length; i++) {
18+
var attachmentGR = new GlideRecord('sys_attachment');
19+
attachmentGR.initialize();
20+
attachmentGR.table_name = 'incident'; // Link to the incident table
21+
attachmentGR.table_sys_id = incidentID; // Link to the newly created incident
22+
attachmentGR.file_name = attachments[i].file_name; // Attach the file name
23+
attachmentGR.content_type = attachments[i].content_type; // Attach the content type
24+
attachmentGR.insert(); // Save the attachment
25+
}
26+
}
27+
})();
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Description
2+
The Incident Creation from Email with Attachments Handling functionality in ServiceNow allows users to create incident records directly from incoming emails.
3+
This automation streamlines the incident management process, enabling users to report issues efficiently without the need to log
4+
into the ServiceNow platform. When an email is received, the script extracts critical information from the email, such as the subject and
5+
body, to populate the incident fields. Additionally, any attachments
6+
included in the email are automatically linked to the incident, ensuring that all relevant context is preserved and easily accessible for support teams.
7+
8+
Key Features :
9+
1) Automatic Incident Creation: Converts incoming emails into incident records, minimizing manual data entry.
10+
11+
2) Dynamic Field Population:
12+
Short Description: Uses the email subject as the incident short description.
13+
Detailed Description: Captures the email body as the incident description.
14+
Caller Identification: Automatically sets the email sender as the incident caller for accurate tracking.
15+
16+
3) Attachment Support: Handles multiple attachments, linking them to the incident record for context.
17+
18+
4) Customizable Logic: Easily modify the script to route incidents based on keywords in emails.
19+
20+
5) Error Handling and Logging: Integrates error handling to log issues during the incident creation process.
21+
22+
6) Enhanced User Experience: Enables quick issue reporting via email, improving user satisfaction.
23+
24+
7) Tracking and Reporting: Allows tracking of incidents created via email for analysis of trends and response times.
25+

0 commit comments

Comments
 (0)