Auto Assign Assignment Group Based on Email Sent To

felixmelendes
Kilo Contributor

Hello all.

My company has a need to set up logic to auto assign the assignment group based on the email the request was sent to.

For isntance, if the email is sent to security@conns.com we want the assignment group changed to Security. If sent to our ITHelpdesk@conns.com email we want it sent to auto assign to ITHelpdesk.

I had attempted to achieve this with inbound email actions but ran into an issue   with auto assigning everything to Security assignment group.

Please advise how I could achieve this. I was using a combination of two actions but am sure it can be achieved with just one.

The first "Create Security" inbound action below specifies to auto assign Security group based on email.

Condition: emailTo.indexOf("security@conns.com") >=0

// Define Caller Details

var callerID = gs.getUser().getRecord()

current.caller_id = callerID.getValue('sys_id');

current.location = callerID.getValue('location');

current.u_phone_number = callerID.getValue('phone');

current.contact_type = 'email';

// Define Incident Details

current.assignment_group.setDisplayValue("IT Securities");

current.status = 1;

current.short_description = email.subject;

current.description = email.body_text;

current.insert();

_____________________________

The intent of "Create Incident" inbound action was to create incidents for those not sent to Security@conns.com

// Define Caller Details

var callerID = gs.getUser().getRecord();

var sEmailAddress = email.origemail.toLowerCase();

  if (sEmailAddress.indexOf("security@conns.com") >= 0) {

current.caller_id = callerID.getValue('sys_id');

current.location = callerID.getValue('location');

current.u_phone_number = callerID.getValue('phone');

current.contact_type = 'email';

// Define Incident Details

current.assignment_group.setDisplayValue("IT Helpdesk");

current.status = 1;

current.short_description = email.subject;

current.description = email.body_text;

current.insert();

  }

1 ACCEPTED SOLUTION

Gurpreet07
Mega Sage

Okay,   we were checking for from address but you mentioned that assignment should be on basis of To Address. Following code should work.



  1. // Define Caller Details
  2. var callerID = gs.getUser().getRecord();
  3. var sEmailAddress = email.direct.toLowerCase();
  4.   if (sEmailAddress.indexOf("ithelpdesk@conns.com") != -1) {
  5.   current.assignment_group.setDisplayValue("IT Helpdesk");
  6.   }
  7. else if(sEmailAddress.indexOf("security@conns.com") != -1){
  8. current.assignment_group.setDisplayValue("IT Securities");
  9. }
  10. current.caller_id = callerID.getValue('sys_id');
  11. current.location = callerID.getValue('location');
  12. current.u_phone_number = callerID.getValue('phone');
  13. current.contact_type = 'email';
  14.  
  15. // Define Incident Details
  16. current.status = 1;
  17. current.short_description = email.subject;
  18. current.description = email.body_text;
  19. current.insert();

View solution in original post

6 REPLIES 6

This worked exactly as need. I appreciate your assistance very much.



One final question, if I wanted to expand on this script in the future, can you provide a template where I modify and include the new email / assignment group code?



// Define Caller Details


var callerID = gs.getUser().getRecord();


var sEmailAddress = email.direct.toLowerCase();


  if (sEmailAddress.indexOf("ithelpdesk@conns.com") != -1) {


  current.assignment_group.setDisplayValue("IT Helpdesk");


  }


  else if(sEmailAddress.indexOf("security@conns.com") != -1){


  current.assignment_group.setDisplayValue("Security");


  }


current.caller_id = callerID.getValue('sys_id');


current.location = callerID.getValue('location');


current.u_phone_number = callerID.getValue('phone');


current.contact_type = 'email';



// Define Incident Details


current.status = 1;


current.short_description = email.subject;


current.description = email.body_text;


current.insert();


Gurpreet07
Mega Sage

You just need to add else if condition for new assignment group




// Define Caller Details


var callerID = gs.getUser().getRecord();


var sEmailAddress = email.direct.toLowerCase();


  if (sEmailAddress.indexOf("ithelpdesk@conns.com") != -1) {


  current.assignment_group.setDisplayValue("IT Helpdesk");


  }


  else if(sEmailAddress.indexOf("security@conns.com") != -1){


  current.assignment_group.setDisplayValue("Security");


  }


  else if(sEmailAddress.indexOf("newAddress@conns.com") != -1){


  current.assignment_group.setDisplayValue("New Group");


  }



current.caller_id = callerID.getValue('sys_id');


current.location = callerID.getValue('location');


current.u_phone_number = callerID.getValue('phone');


current.contact_type = 'email';



// Define Incident Details


current.status = 1;


current.short_description = email.subject;


current.description = email.body_text;


current.insert();