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

mohanambalnanja
Tera Contributor

Hi ,

 

I guess the below link might help you to resolve your issue. Please check.

 

Need help to fetch values for inbound action email - ServiceNow Community

 

Thanks & Regards,

Anitha H V