Inbound action - Can't get company information

_Pedro
Tera Contributor

Hello!

 

Newbie here and having a hard time getting this to work. I am aiming for this inbound action to capture the company from the email subject and based on it fill the company name, technical_offering and service_offering. Problem is it does not capture the company at all. Help and explanations are very welcome!

(function runAction(current, event, email, logger, classifier) {
    var company = email.subject.split('|')[1].trim();
    var companyName = new GlideRecord('core_company');
    companyName.addQuery('name', 'CONTAINS', company);
    companyName.query();


    var companySysId = companyName.sys_id;
    current.caller_id = gs.getUserID();//good
    current.short_description = email.subject;//good
    current.description = email.body_text;//good
    current.category.setDisplayValue('administrative_work');
    current.company = companySysId;//.getValue('name');
    current.technical_offering = companySysId.getValue('technical_offering');
    current.service_offering = companySysId.getValue('service_offering');

    var contactRecord = new GlideRecord('sys_user');


    if (companySysId.getValue('service_offering')) {
        contactRecord.get(companySysId.getValue('service_offering'));


        if (contactRecord.next()) {
            current.assigned_to = contactRecord.sys_id;
        }
    }

    if (email.body.assign != undefined)
    current.assigned_to = email.body.assign;

 

    // Create the incident and get the incident ID
    var incidentID = current.insert();


    gs.info('Incident created with ID: ' + incidentID);

})(current, event, email, logger, classifier);

0 REPLIES 0