Inbound Email Action Query
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2023 02:13 AM
when i sent email to servicenow based on that email one case will be created in servicenow . In the mail i give short description and con figuration Item . that information is set in short description and configuration Item in case Form. How to write Inbound Email Action in servicenow case is create based on prefix in subject that subject is ' Case'.. Configuration Item is Reference field in Case Form.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2023 12:47 AM
Hi @Anusha Medharam ,
There's an out of the box Inbound Email Action "Create Case via property" present to create Case from incoming email with all the fields, after validating that To address is mentioned in the property glide.cs.email.case_queue_address.
But, in your case you need to create a case based on prefix, so it would be better to clone this inbound action by using Insert & Stay functionality and then adding a script after the existing one.
Note: Set the order of execution of new inbound action less than the OOTB one.
You can also, refer below sample code for inbound action :
(function runMailScript(email, template, email_action, email_table, email_record) {
// Check if the email subject starts with "Case"
if (email.subject.startsWith('Case')) {
// Create a new case record
var newCase = new GlideRecord('sn_customerservice_case');
newCase.initialize();
// Set short description from the email body
newCase.short_description = email.body_text;
// Set configuration item (replace 'YOUR_CI_NAME' with the actual configuration item name)
newCase.configuration_item = 'YOUR_CI_NAME';
// Set other fields as needed
// Insert the new case record
var caseSysID = newCase.insert();
// Log the created case sys_id
gs.info('New Case Created: ' + caseSysID);
// Stop further processing of the email
return;
}
})(email, template, email_action, email_table, email_record);
Thanks,
Ratnakar