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

Gurpreet07
Mega Sage

Try this with only one inbound action . Code something like below


  1. // Define Caller Details  
  2. var callerID = gs.getUser().getRecord();  
  3. var sEmailAddress = email.origemail.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.    
  20. current.insert();  

Gurpreet,



Thank you for your response and assistance. I attempted to use the script you provided. It processes without error but the incident's are not being auto assigned to either IT Helpdesk or the IT Securities group.



What info can I provide to further assist?



Your time and assistance is greatly appreciated.


Gurpreet07
Mega Sage

Hi Felix,


Try to put some log statements in the code to know the flow. If control is entering in any of the if/else conditions and still its not working then you could try to assign assignment group using sys_id of respective group.



  1.   if (sEmailAddress.indexOf("ithelpdesk@conns.com") != -1) {
  2. gs.log("Email From :"+ithelpdesk@conns.com);
  3.   current.assignment_group.setDisplayValue("IT Helpdesk");         //replace with current.assignment_group = sys_id_of_group
  4.   }
  5. else if(sEmailAddress.indexOf("security@conns.com") != -1){
  6. gs.log("Email From :"+security@conns.com);
  7. current.assignment_group.setDisplayValue("IT Securities");         //replace with current.assignment_group = sys_id_of_group
  8. }

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();