Create a Request Item using data passed in Inbound Email in ServiceNow

Community Alums
Not applicable

Hi There,

 

I have a requirement to create a request item when the below data is passed to ServiceNow's mail ID using Inbound Email Action. Below is the fixed format ServiceNow will be receiving, want to understand how to parse the data in :

 

Region: AMER

Country: Canada (Reference field)

Company: Test Canada Inc. (Reference field)

City: Montreal (Reference field)

Department: Information Technology (IT) (Reference field)

SF ID: 123000

Employee ID: 123000

Cost Center: 000123

Job Title: 

Personal Title: 

First Name: Test Onboarding

Legal Name: 

Last Name: ServiceNow

Date of Joining: 2024-06-15

Line Manager: Tejas Test

Line Manager Email: tejas.test@test.com

Ticket URL: 

Ticket ID: SR-114283

 

Thanks,

Tejas

16 REPLIES 16

Hi @Community Alums ,

 

Can you share your inbound actions condition and also check "Create Incident" inbound action condition (this could be triggering in your case).

 

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

Community Alums
Not applicable

Hi @Hemanth M1 

 

I have checked no other inbound email integration is getting triggered

 

Condition:

 

Subject contains 'Onboarding Request (Global-IT) for user'

 

Script:

 

createRequest();

function createRequest() {

    var mgr = ''; // You can use this line to set a default
    var ctry = '';
    var cmny = '';
    var city = '';
    var dept = '';

    var gr = new GlideRecord('sys_user');
    if (gr.get('name', email.body.manager_name)) {
        mgr = gr.sys_id;
    }
    var gr1 = new GlideRecord('core_country');
    if (gr1.get('name', email.body.country)) {
        ctry = gr1.sys_id;
    }
    var gr2 = new GlideRecord('core_company');
    if (gr2.get('name', email.body.company)) {
        cmny = gr2.sys_id;
    }
    var gr3 = new GlideRecord('u_city');
    if (gr3.get('u_city', email.body.city)) {
        city = gr3.sys_id;
    }
    var gr4 = new GlideRecord('cmn_department');
    if (gr4.get('name', email.body.department)) {
        dept = gr4.sys_id;
    }

    var cartId = GlideGuid.generate(null);
    var cart = new Cart(cartId);
    // add in cart, substitute your cat item sys_id
    var item = cart.addItem('b106bc193bce4610ea3a202a85e45aeb');
    // set requested for, substitute your requested for
    //Set Variables in your Cart Item
    cart.setVariable(item, 'select_the_account', 'Internal');
    cart.setVariable(item, 'region', email.body.region);
    cart.setVariable(item, 'country', ctry);
    cart.setVariable(item, 'company', cmny);
    cart.setVariable(item, 'city', city);
    cart.setVariable(item, 'department', dept);
    cart.setVariable(item, 'line_manager', mgr); // Note the change here
    cart.setVariable(item, 'successfactor_id', email.body.sf_id);
    cart.setVariable(item, 'employee_number', email.body.employee_id);
    cart.setVariable(item, 'job_title', email.body.job_title);
    cart.setVariable(item, 'personal_title', email.body.personal_title);
    cart.setVariable(item, 'first_name', email.body.first_name);
    cart.setVariable(item, 'last_name', email.body.last_name);
    cart.setVariable(item, 'legal_name', email.body.legal_name);
    cart.setVariable(item, 'date_of_joining', email.body.date_of_joining);
    //cart.setVariable(item, 'line_manager_email', email.body.line_manager_email);
    var cartmsg = "received from: " + email.origemail + "\n\n" + email.body_text;
    cart.setVariable(item, 'comments', cartmsg);
    var rc = cart.placeOrder();
}

Hey @Community Alums ,

 

Can you check email logs to see the executions and whats your inbound action conditions (when to run conditions)

 

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

Community Alums
Not applicable

Hi @Hemanth M1 ,

 

The only condition mentioned in When to run is:

 

Subject contains 'Onboarding Request (Global-IT) for user'

 

The Email execution is

Tejas12_0-1718163635476.png

 

 

Hi @Community Alums ,

 

Target table should be sc_request, action type = record action  and update execution order to 50 (just to run the inbound at a higher oder)

 

HemanthM1_0-1718163949373.png

 

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025