Inbound Action Correlation ID
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2025 08:45 AM
Hello everyone,
I've been asked to use an Inbound Action to populate the correlation ID field in ServiceNow for the INC in question with the Remedy Incident number from an associated email. All Remedy emails follow the same pattern: the email body is RE: INC0000XXXXXXXX (where XXXXXXXX is 8 digits).
I've added this code to complete the process and would like to know if it's targeted correctly.
Thank you very much, and best regards.
gs.include('validators');
if (current.getTableName() == "incident") {
var gr = current;
if (email.subject.toLowerCase().indexOf("please reopen") >= 0)
gr = new Incident().reopen(gr, email) || gr;
gr.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;
// Respuesta del proveedor
if (gr.state == 3 && gr.u_vendor.email == email.origemail) {
gr.state = 2;
}
// Cambio de estado a "Work in Progress" si el correo es de @minsait.com o @indracompany.com
var senderEmail = email.origemail.toLowerCase();
if (senderEmail.includes("@minsait.com") || senderEmail.includes("@indracompany.com") || senderEmail.includes("@devoteam.com")) {
gr.state = 2;
}
if (gs.hasRole("itil")) {
if (email.body.assign != undefined)
gr.assigned_to = email.body.assign;
if (email.body.priority != undefined && isNumeric(email.body.priority))
gr.priority = email.body.priority;
}
// Extraer el número de referencia de Remedy desde el asunto
var subject = email.subject;
var match = subject.match(/INC\d{8}/);
if (match) {
var remedyReference = match[0]; // Captura el número encontrado
// Asignar el valor al campo correlation_id
if (remedyReference) {
gr.correlation_id = remedyReference;
}
}
gr.update();
}
0 REPLIES 0