Inbound email action issue

mohanambalnanja
Tera Contributor

Hi,

 

I have created an inbound action to create "incident" whenever email is received from specific email ID and subject.

While testing, I have sent an email from my email ID with specific subject. Incident is created when I sent an email from my email ID. But it didn't create the incident when the email is from that specific email ID. Email ID is present in ServiceNow.

Below is my script. 

 

var callerEmailAddress = email.body.caller;             //Set Caller Details
    var user = new GlideRecord('sys_user');
    user.addQuery('email', callerEmailAddress);
    user.query();

 

    if (user.next())
    {
        current.caller_id = user.sys_id;
    }

    var configurationItemName = email.body.dashboard_name; // Set Configuration Item
    var configurationItem = new GlideRecord('cmdb_ci');
    configurationItem.addQuery('name', configurationItemName);
    configurationItem.query();

    if (configurationItem.next())
    {
        current.setValue("cmdb_ci", configurationItem.sys_id);
    }

    var businessServiceName = email.body.business_service; // Set Business Service
    var businessService = new GlideRecord('cmdb_ci_service');
    businessService.addQuery('name', businessServiceName);
    businessService.addQuery('u_active', true);
    businessService.query();

    if (businessService.next())
    {
        current.setValue("u_business_service", businessService.sys_id);
    }

    var group = email.body.assignment_group;                // Set Assignment Group
    var GROUP_TYPE_ASSIGNABLE = "463cd4901b38e510c900a6c7b04bcbeb";
    var userGroup = new GlideRecord('sys_user_group');
    userGroup.addQuery("type", "LIKE", GROUP_TYPE_ASSIGNABLE);
    userGroup.addQuery("name", group);
    userGroup.query();

    if (userGroup.next())
    {
        current.setValue("assignment_group", userGroup.sys_id);
    }

    var workNotes = '\nWork Notes: '+email.body.work_notes;  //Update work notes
    var owner = '\nOwner: ' + email.body.owner;            
    var developerEmailID = '\nDevelopers Email Ids: ' + email.body.developers_email_ids;
    var requestedEmailID = '\nRequested Email Ids: ' + email.body.requested_email_ids;
    var dashboardURL = '\nDashboard URL: ' + email.body.dashboard_url;
    var region = '\nRegion: ' + email.body.region;
    var country = '\nCountry: ' + email.body.country;
    var brachName = '\nBranch Name: ' + email.body.branch_name;

    current.work_notes = workNotes+owner + developerEmailID + requestedEmailID + dashboardURL + region + country + brachName;
    current.insert();
}
 
11 REPLIES 11

tharun_kumar_m
Mega Guru

Hi @mohanambalnanja ,

 

Please ensure that the email id from which you are sending the email does not have an inactive profile associated with it in ServiceNow.

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumbs up.

 

Best regards,

Tharun Kumar

Hi Tharun,

 

I checked the profile. It is active.

 

Thanks

Dhananjay Pawar
Kilo Sage

Hi,

Please check the email properties. Check is there any restriction on receiving the emails from particular domain.

 

Thanks,

Dhananjay.

mohanambalnanja
Tera Contributor

There are some changes in my Post. Incident is getting created. But the values are not mapped as per the script in incident form.

 

When the email is sent from my email ID, the fields are mapped as per the requirement.