ServiceNow Inbound Email Does Not Trigger

aungmon
Tera Contributor

Hi All

 

I am working on ServiceNow Tokyo instance.

 

Have created a flow in flow designer to create new record when inbound email contains specific keywords in subject.

 

The flow is working fine and the conditions are evaluated 'true' in execution details when I run "Test Flow" but after published and actual email coming in (inbound email), the flow did not triggered. Email record is created, processed and park under "Inbound > Received" mailbox.

 

aungmon_0-1678949958486.png

aungmon_1-1678951889588.png

 

Kindly please advise where should I further investigate and missed out anything.

 

Thanks.

 

 

 

15 REPLIES 15

Hello,

We are facing the same issue as per above screenshot.  We are not getting any email logs when inbound email is received. 

The main challenge we're facing currently is this: when we send an email from an unknown user, a case is created, and a new contact is generated with the sender's details. However, once the user becomes existing in the system and we resend an email to check if the contact field on the case form populates with the sender's existing information, we received the email but the case isn't created automatically as expected. 
Kindly please advise what should I further investigate to resolve this issue..

Thank you!

current.short_description = email.subject;
//current.description = email.body_text;

if (email.user == '') {
    var email_body = email.body_text;
    current.description = email.from + '\r' + email_body;
} else {
    current.description = email.body_text;
}


var contact = new GlideRecord("customer_contact");
var contactID = new CSEMailUtil().getUserIDFromEmail(email.from);
if (contact.get(contactID)) {
    var accountID = contact.account;
    var account = new GlideRecord("customer_account");
    if (account.get(accountID)) {
        if (account.customer) {
            current.contact = contact.sys_id;
            current.account = account.sys_id;
        }
    }
}

current.contact_type = "email";
//current.product = new CSEMailUtil().getProductFromPrefix(email.subject);  
current.insert();

var emailAddress = email.from;
var parts = emailAddress.split('@');
var domain = parts[1];
var reqDomain = '@' + domain;

var customerAccount = new GlideRecord('customer_account');
customerAccount.addQuery('u_trusted_email_domain_s', reqDomain);
customerAccount.query();

if (customerAccount.next()) {
    current.account = customerAccount.sys_id;

    var customerContact = new GlideRecord('customer_contact');
    customerContact.addQuery('account', customerAccount.sys_id);
    customerContact.addQuery('email', email.origemail);
    customerContact.query();
   

    if (customerContact.next()) {

        current.contact = customerContact.sys_id;
       

    } else {
        customerContact.initialize();
        customerContact.name = gs.getUserDisplayName(email.user_id);
        customerContact.account = customerAccount.sys_id;
        customerContact.email = email.origemail;
        var newContact = customerContact.insert();
        current.contact = newContact;
       
    }

} else {
    var defaultAcc = gs.getProperty('sn_customerservice.default.account');
    current.account = defaultAcc;

    var defaultContact = gs.getProperty('sn_customerservice.default.contact');
    current.contact = defaultContact;
}

current.update();
We have created a script as above and we have used this script in our inbound action to autopopulate account and contact field on the customer_case form.

Community Alums
Not applicable

Hello @aungmon ,

 

Could you add the snippets of the flow running or actions executing after record creation.

Hi Anand

 

The flow does not trigger when inbound email coming in. The flow is "Published" and it is "Active".

 

I am not sure which snippets you are referring to.

 

But when I run "Test Flow" it was working, please refer below screenshot.

 

aungmon_0-1678967491058.png

 

Community Alums
Not applicable

Hi @aungmon ,

 

Move the if condition to the trigger condition and then try, I have checked worked fine for me.

AnandMahajan_0-1678969704661.png

AnandMahajan_1-1678969710705.png

 

AnandMahajan_2-1678969758831.png

 

If this solves your query, mark this as helpful and correct.

 

Regards

Anand