Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

if sender is abel tuter@service now.com, create the incident ticket with contents of the email. create incident ticket to technical group with short description software issue and create another incident ticket for cmdb group with short description w

Mandhula Harish
Kilo Contributor

For example:-

if sender is abel tuter@service now.com, create two incident tickets with contents of the email and assign to two different assignment groups.

create incident ticket to

1. Technical group with short description as "software issue"     and

2. create another incident ticket for cmdb group with short description as "windows server".

1 ACCEPTED SOLUTION

Imran Ahmad1
Mega Guru

 

find_real_file.png

find_real_file.png

 

find_real_file.png

 

 

Hii @Mandhula Harish,
 

You can also try this code to achieve your requirement, It's easy to understand the logic and Tested by me:-

create Inbound Email Action

In Action tab copy and paste below code and change sys id as per your business requirement.

 

(function runAction(/*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
    
    
var group = ["019ad92ec7230010393d265c95c260dd","0a52d3dcd7011200f2d224837e6103f2"]; // Instead of passing sys_id in code try to create system properties and call it in array name is group its good pratice and recommended by servicenow.
    
    var short_description = ["software issue","windows server"];
    var j = 0;
    for(var i = 0 ; i<= group.length-1;i++){        
        
    var gr = new GlideRecord("incident");
    gr.intialize();
    gr.assignment_group = group[i];
    gr.short_description = short_description[j];
        gr.description = email.body_text;
            gr.insert();
        j=j+1;
    
        }
    

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

 

 

 

Regards,

Imran Ahmad

 

 

Please send your feedback

Please Mark helpful below:-

View solution in original post

11 REPLIES 11

shloke04
Kilo Patron

Hi @Mandhula Harish 

Couple of things you need to take care of to achieve your requirement:

1) There is an OOB Inbound action which you need to update and add a condition that it should not get trigger when "abel.tuter" is sending the email . This is required because it will not collide with your New Inbound action which you need to write for your scenario.

Please navigate to below link:

https://instance.service-now.com/nav_to.do?uri=sysevent_in_email_action.do?sys_id=3ccfeff5c611227a0180144333c87af9

Replace "instance' with your instance name.

Add a condition as shown below first:

email.from !='Put the email id of Abel Tuter here in quotes';

find_real_file.png

Now you need to create a new Inbound action, so navigate to the Module "Inbound email actions" as shown below:

find_real_file.png

Click on New and create a new Inbound action as shown below to achieve your requirement:

find_real_file.png

Now use the Script in Inbound action as shown below which will create two incident and also assign it to different groups as you want with different short description:

(function runAction(/*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {

	// Implement email action here
	createFirstIncident('software issue','Sys id of your Assignment Group',email.body_text);
	createSecondIncident('windows server','Sys id of your Assignment Group',email.body_text);
	
	function createFirstIncident(shortDescription,AssignmentGroupID,emailBody){
		createRecord(shortDescription,AssignmentGroupID,emailBody);	
	}
	function createSecondIncident(shortDescription,AssignmentGroupID,emailBody){
		createRecord(shortDescription,AssignmentGroupID,emailBody);	
	}
	
	function createRecord(shortDescription,AssignmentGroupID,emailBody){
		var gr = new GlideRecord('incident');
		gr.initialize();
		gr.short_description = shortDescription;
		gr.assignment_group = AssignmentGroupID;
		gr.description = emailBody;
		gr.insert();
	}
	
	
		


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

find_real_file.png

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hi Shloke,

How can we test this in service now

Send an email to your ServiceNow instance and then you can test this.

Say for example if you are doing it in your personal instance then send an email to your instance which will be below:

devxxxxx@service-now.com

Make sure the email from which you are sending the email say suppose your personal email id , then that email id is present in User Table as one of the User record and also update the same email id as mentioned above in screenshot by me.

Also make sure email receiving capability is ON as shown below:

 

 

find_real_file.png

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

can we test this by using outbound emails

Hi @Mandhula Harish 

You need to be sure on what exactly is the requirement here which you are trying to achieve and you need to provide the same here exactly what you need.

To clarify based on what you have provided the details above, You should be using Inbound Email only  and not Outbound functionality here.

Method which I have suggested above works fine in my PDI instance and does exactly what you need as per details shared.

Now just to clarify here:

Inbound: When some one is sending email to ServiceNow instance and then you need to do certain actions.

Outbound: When you create or Update something in ServiceNow, then you need to do certain actions.

I don't see any purpose why would you like to create 2 or more incident when some one send an oUtbound email here, I might be missing something here, can you let me know the use case.

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke