Email script

Sironi
Kilo Sage

Hi,

someone help on incident script,

send  incident details list to assigned to if incident state is OnHold on single notification .

ex: DavidLoo hasbeen assigned to 10-incidents , in 10-incidents there are 7 incidents have state -onhold. so DavidLoo should receive 7-incident details (number, shortdescription, caller , priority)  in a single email.

i tried with below script, it is getting single incident details, how to get all in single email.

template.print("number :"+"${number}\n");

template.print("number :"+"${priority}\n");

template.print("number :"+"${caler_id}\n");

template.print("number :"+"${short_description}\n");

 

1 ACCEPTED SOLUTION

Hi,

I just updated the job code

It triggered 3 emails to 3 different users

Email triggered to David Loo has incident info Assigned to David Loo

Email triggered to Rosie Mathews has incident info Assigned to Rosie Mathews

Email triggered to Fred Luddy has incident info Assigned to Fred Luddy

Now the only thing you need to check is why it didn't send email to other 6 users

Updated Job Code:

sendEmail();

function sendEmail() {

	var gr = new GlideAggregate("incident");
	gr.addAggregate("COUNT");
	gr.addEncodedQuery('active=true^assigned_toISNOTEMPTY');
	gr.groupBy("assigned_to");
	gr.query();
	while(gr.next()) {
		var user = gr.assigned_to;
		var incRec = new GlideRecord('incident');
		incRec.get('assigned_to', user);
		gs.eventQueue('test_list', incRec, incRec.assigned_to, incRec.assigned_to);
	}
}

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

46 REPLIES 46

Hi Ankur,

Thanks for your support and script. i just check it.

can you help me, why mails not sending to  Assigned_to persons? it is sending to only Admin.

find_real_file.png

 

@Sironi 

I believe everything other that this is looking good.

You can close the thread as answered by marking reply as correct and helpful

Did you check that assigned_to user has this

1) valid email address format

2) that user has notification preference enabled so as to receive the email

3) is active and not locked out

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

sure, please help me in this case only.

i just added David Loo into at notification side, he is not getting emails.

David Loo is in Active .

find_real_file.png

 

find_real_file.png

Hi Sironi,

Is it going to other users except David Loo?

if yes then please check configuration for that user

- email present or not; not locked out etc

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

i just activated email configuration for DAvid Loo,'

David Loo has 2 incidents. so he has to receive one email along with those 2-incident details . but here it is sending two email.

find_real_file.png