How to parse specific content from an email subject to set a field value

Jerome MAISETTI
Mega Guru

Hello
Today, we are using inbound action to put emails in tickets.
I would like to parse the subject of certains emails and put a certain string into a field.
I receive emails from specific email addresses with this reference in the subject SMIT-xxxx and I would like to set the field 'Salesforce ticket reference" to this value in the task table.
Can you help me to achieve this ?
I searched a bit left and right but I'm not sure how to do this , do I have to create a separate inbound action or is it a business rule ?
Thanks
Jérôme

1 ACCEPTED SOLUTION

Jerome MAISETTI
Mega Guru

I managed to do it :

ParseSmit();

function ParseSmit() {

    // The subject
    var subjectStr = email.subject;
    var regExSmit = /SMIT-\d{4}/;
    var ciStr = subjectStr.match(regExSmit);
    gs.log(ciStr);
    current.u_jira_ticket_reference = ciStr[0];
    current.update();
    
}

View solution in original post

15 REPLIES 15

One thing to keep in mind, your email should have some sort of identifier for the incident record, whether it should be a reply to the email sent from servicenow or incident number should be there in the email

 

There is always the snow ticket number in the subject, but I have now to be able to match the correct case from this in the subject I think

The system recognises that, try with the code that I have shared 

I tried multiple times but it still doesn't work unfortunately 😞

Jerome MAISETTI
Mega Guru

I managed to do it :

ParseSmit();

function ParseSmit() {

    // The subject
    var subjectStr = email.subject;
    var regExSmit = /SMIT-\d{4}/;
    var ciStr = subjectStr.match(regExSmit);
    gs.log(ciStr);
    current.u_jira_ticket_reference = ciStr[0];
    current.update();
    
}