Inbound email action case creation

Vaishali 11
Tera Guru

I have created 1 inbound email action which is currently checking if the user is an external one and setting the opened for and opened by as guest. The piece of code is as follows:-

current.priority = 3;

var bodyText = email.body_text;
if (!bodyText)
    bodyText = email.body_html;

current.work_notes = "HR Case created by email:\n\nReceived from: " + email.origemail + "\n\n" + email.subject + "\n\n" + bodyText;
current.description = bodyText;
var profile;
if (gs.getUserID() == gs.getProperty('sn_hr_core.guest_user')) {   //GUEST SYS_ID
current.opened_by = gs.getUserID();
        current.opened_for = gs.getUserID();
} else {
    // Find and attach profile if it exists
    current.opened_by = gs.getUserID();
    current.opened_for = gs.getUserID();
    profile = new GlideRecord('sn_hr_core_profile');
    profile.addQuery('user', gs.getUserID());
    profile.addNotNullQuery('user');
    profile.query();
    if (profile.next())
        current.hr_profile = profile.sys_id;
}

current.subject_person = current.opened_for;
var newId = current.sys_id;
gs.eventQueue('sn_hr_core_case.email.creation', current, newId, email.from);
 
 
this was earlier working but now we have introduced vendor management and now in the sys_user table for vendor the record is created as class vendor contact. In this scenario the inbound email action is not able to identify any emails coming from a vendor and hence is not able to create a case. 
How can I incorporate this in my above code so that it checks if the sys_user class= vendor contact and if

so subject for = guest, and opened by and opened for UserId?

0 REPLIES 0