Inbound Action from specific group

Baggies
Kilo Guru


I was trying to create an Inbound Action where the senders are all part of the same group. The type needs to be forwarded. I have come up with an Action that will work with a list of users, which may be helpful to someone.

I was wondering how to create a condition that looks at the user who forwarded the email, checks their group, and if they are a member of a specific group, processes the inbound action. I have the order , and email processing order plugin sorted out, so I know when to stop processing the action. A also thought I could use the 'from:' field.

Maybe the answer is in my script, something like "from.group == "Service-Desk" {

Any suggestions welcome if someone has done this already. Here's what I have for specific users if anyone needs something similar. Many thanks, Mark S.

 

type=forward, co condition, uses validators.

 

gs.include('validators');
var from = gs.createUser(email.body.from);

//need more than one email address to work with validators
if (from == "john.doe@somewhere.com"||"james.doe@thisplace.com")

    {
      current.opened_by = from;
      current.caller_id = email.from;
      current.assignment_group = "sys_id of assignment group here";
      current.assigned_to = email.from;
      current.state = 1;
      current.contact_type = "email";
      current.short_description = email.subject;
      current.description = "Email received from: " + email.origemail + "\n" + "Email copied to: " + email.to + "\n" + "Subject: " + email.subject + "\n\n" + email.body_text;
      //send to log user who forwarded email.

      gs.log("***Inbound Action from " + email.body.from);
      event.state="stop_processing";
}

1 ACCEPTED SOLUTION

Jim Coyne
Kilo Patron

This may look convoluted, but set this as your condition:



gs.getUser(). ­getUserByID( ­sys_email.getValue("user_id")). ­isMemberOf( ­"GroupName")



It creates a user object [gs.getUser()], fetches the user record for the user that sent the email [ ­getUserByID( ­sys_email.getValue("user_id"))] and checks to see if the user is a member of a particular group [ ­isMemberOf( ­"GroupName")].   "sys_email" is a GlideRecord of the email that is being processed.


View solution in original post

9 REPLIES 9

Baggies
Kilo Guru

I have tried bother the methods here, and I thank you for your responses.


With the script I have, I get a log message:


"Skipping 'Create Incident EAS TEST 6', did not create or update incident"


Also the log shows "*** 1 - Inbound Action fromcom.glide.sys.User@9d56d2" for my gs.log capture. I know you have "abel.tutor" in your script, but what am I supposed to replace it with? email.from? Cheers, Mark S.


My latest version is :



var myUserObject = gs.getUser();


myUserObject = myUserObject.getUserByID('abel.tuter'); //Pass sys_id or User Id


gs.log("*** 1 - Inbound Action from" + myUserObject);


if(myUserObject.isMemberOf('ServiceNow Administrators') || myUserObject.isMemberOf('IT - ServiceNow Support')){


        current.urgency = 1;


      current.impact = 1;


      current.opened_by = from;


      current.caller_id = email.from;


      current.assignment_group = "33194bd90a0a3ce00100f0f13b5f845e";


      current.state = 1;


      current.contact_type = "email";


      current.short_description = email.subject;


      gs.log("*** 2 - Inbound Action from" + myUserObject);


     


      current.insert();


      event.state="stop_processing";


}


Jim Coyne
Kilo Patron

This may look convoluted, but set this as your condition:



gs.getUser(). ­getUserByID( ­sys_email.getValue("user_id")). ­isMemberOf( ­"GroupName")



It creates a user object [gs.getUser()], fetches the user record for the user that sent the email [ ­getUserByID( ­sys_email.getValue("user_id"))] and checks to see if the user is a member of a particular group [ ­isMemberOf( ­"GroupName")].   "sys_email" is a GlideRecord of the email that is being processed.


Better late than never, but the condition option worked perfectly, thanks for the help


Baggies
Kilo Guru

Many thanks again for the excellent responses, certainly good for my brain. Creating the condition seems to have done the trick, I just have to test a few times, and i should be good. Once that is done, I'll will close the discussion appropriately. Thanks Mandar, Solutioner, and Jim Coyne for his last reply.


Forgot to add this snippet from ServiceNow:


About Rollbacks and Backups


When planning an upgrade, note that ServiceNow does not provide a rollback option or perform on-demand backups. Instances are automatically backed up daily during non-peak business hours on schedules defined by ServiceNow. We do not adjust the timing of existing backup schedules.  


Avoid restoring a production instance from backup, when possible, due to downtime and data loss. Restoring a production instance from backup is a final option when a problem cannot be solved using other methods. We provide customer support 24/7 to provide assistance with critical post-upgrade issues.


The best method for successfully upgrading a production instance is to first test thoroughly on a sub-production instance. The testing process explained on this wiki page helps identify critical problems and related fixes on the sub-production instance. Use the information identified during testing to create a plan for addressing issues after upgrading the production instance.