Category on INC/SRQ

Varun Naidu
Giga Contributor

Hi Experts!!!!

 

Need some help here.

The scenario is 

When a ticket is created by an email and it is not mapped to a category.

But a user has selected the category as Inquiry/help which is not available in u_category.LIST table.

Please help me here in order to find the issue.

 

 

Thanks in Advance.

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Narayan,

Can you explain your issue in detail?

From what you mentioned it seems through inbound email action when incident is created category value is not present and hence not mapped.

What next?

Regards

Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur thank you for the quick reply.

 

the isssue is a ticket was created by sending an email to servicenow and it didnt pick the category.

Later a user has added the category as inquiry/help which doesnot exist in u_category.LIST table I want your help to know how the category was selected when it doesnot exists.

 

 

Thanks,

Narayan

 

 

Hi Narayan,

What type of table is Category? Is it drop down or reference? It seems the category was not present in the drop down/reference table and inbound email action created the value as extra choice.

Can you share your inbound email action script?

Regards

Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Here is the script 

 

setCategory: function() {

var matched = false;

var categoryMapping = new GlideRecord('u_customer_email_cat_mapping');
categoryMapping.addQuery('u_practice', current.u_practice);
var query = categoryMapping.addNullQuery('u_customer');
query.addOrCondition('u_customer', current.caller_id.company);
categoryMapping.orderByDesc('u_customer');
categoryMapping.orderBy('u_order');
categoryMapping.query();

while (!matched && categoryMapping.next()) {
try {
if (categoryMapping.u_email_to_address_match_strin != '') {
//var toAddressPattern = new RegExp(categoryMapping.u_email_to_address_match_strin, 'i');
var toAddressPattern = new SNC.Regex('/' + categoryMapping.u_email_to_address_match_strin.trim() + '/i');
if (toAddressPattern.match(email.to) !== null) {
current.u_category = categoryMapping.u_category;
if (categoryMapping.u_category.u_assignment_group != '') {
current.assignment_group = categoryMapping.u_category.u_assignment_group;
gs.log('dvEmailHelpers::SetCategory-AssignmentGroup:' + categoryMapping.u_category.u_assignment_group);
}
matched = true;
current.work_notes.setJournalEntry('Category set by category mapping record: ' + categoryMapping.u_customer.name + '/' + categoryMapping.u_order + ' (' + categoryMapping.sys_id + ')');
}
}

if (!matched && categoryMapping.u_email_address_match_string != '') {
//var addressPattern = new RegExp(categoryMapping.u_email_address_match_string, 'i');
var addressPattern = new SNC.Regex('/' + categoryMapping.u_email_address_match_string.trim() + '/i');
if (addressPattern.match(email.from) !== null) {
current.u_category = categoryMapping.u_category;
if (categoryMapping.u_category.u_assignment_group != '') {
current.assignment_group = categoryMapping.u_category.u_assignment_group;
gs.log('dvEmailHelpers::SetCategory-AssignmentGroup:' + categoryMapping.u_category.u_assignment_group);
}
matched = true;
current.work_notes.setJournalEntry('Category set by category mapping record: ' + categoryMapping.u_customer.name + '/' + categoryMapping.u_order + ' (' + categoryMapping.sys_id + ')');
}
}

if (!matched && categoryMapping.u_email_subject_match_string != '') {
//var subjectPattern = new RegExp(categoryMapping.u_email_subject_match_string, 'i');
var subjectPattern = new SNC.Regex('/' + categoryMapping.u_email_subject_match_string.trim() + '/i');
if (subjectPattern.match(email.subject) !== null) {
current.u_category = categoryMapping.u_category;
if (categoryMapping.u_category.u_assignment_group != '') {
current.assignment_group = categoryMapping.u_category.u_assignment_group;
gs.log('dvEmailHelpers::SetCategory-AssignmentGroup:' + categoryMapping.u_category.u_assignment_group);
}
matched = true;
current.work_notes.setJournalEntry('Category set by category mapping record: ' + categoryMapping.u_customer.name + '/' + categoryMapping.u_order + ' (' + categoryMapping.sys_id + ')');
}
}

if (!matched && categoryMapping.u_email_body_match_string != '') {
//var bodyPattern = new RegExp(categoryMapping.u_email_body_match_string, 'i');
var bodyPattern = new SNC.Regex('/' + categoryMapping.u_email_body_match_string.trim() + '/i');
if (bodyPattern.match(email.body_text.substring(0, 10000)) !== null) {
current.u_category = categoryMapping.u_category;
if (categoryMapping.u_category.u_assignment_group != '') {
current.assignment_group = categoryMapping.u_category.u_assignment_group;
gs.log('dvEmailHelpers::SetCategory-AssignmentGroup:' + categoryMapping.u_category.u_assignment_group);
}
matched = true;
current.work_notes.setJournalEntry('Category set by category mapping record: ' + categoryMapping.u_customer.name + '/' + categoryMapping.u_order + ' (' + categoryMapping.sys_id + ')');
}
}
} catch (err) {
gs.log('dvEmailHelpers::setCategory:' + err.message);