# Script in Alarm Pipeline

**URL:** <https://forum.inductiveautomation.com/t/script-in-alarm-pipeline/10573>\
**Category:** Ignition\
**Created:** [October 5, 2015, 2:28pm UTC](https://forum.inductiveautomation.com/t/script-in-alarm-pipeline/10573 "2015-10-05T14:28:52Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![flavien](https://avatars.discourse-cdn.com/v4/letter/f/f475e1/32.png) [@flavien](https://forum.inductiveautomation.com/u/flavien)\
**Post date:** [October 5, 2015, 2:28pm UTC](https://forum.inductiveautomation.com/t/script-in-alarm-pipeline/10573/1 "2015-10-05T14:28:52Z")

</div>

Hi everybody,

In Ignition 7.7, I would like to send an email to only one user of my on-call roster according to a tag which was modified.

For example :

if tag1 \>10 --\> send email to "contact1@box.com"  
if tag2 \>10 --\>send email to “contact2@box.cm”  
etc…

Can I do it in a script block ?

I tried “system.net.sendEmail” function in a script block but I failed.

Thanks for your help,

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [October 5, 2015, 2:33pm UTC](https://forum.inductiveautomation.com/t/script-in-alarm-pipeline/10573/2 "2015-10-05T14:33:51Z")

</div>

What kind of error message did you get?

---

<div class="post-metadata">

**Author:** ![flavien](https://avatars.discourse-cdn.com/v4/letter/f/f475e1/32.png) [@flavien](https://forum.inductiveautomation.com/u/flavien)\
**Post date:** [October 5, 2015, 2:40pm UTC](https://forum.inductiveautomation.com/t/script-in-alarm-pipeline/10573/3 "2015-10-05T14:40:21Z")

</div>

My error message below :

[quote]16:30:40 BlockEvaluationContext [Pipeline: New Pipeline] Error executing scriptable block.

Traceback (most recent call last):  
File “function:handleAlarm”, line 2, in handleAlarm

java.lang.ClassCastException: java.lang.ClassCastException: Cannot coerce value ‘myaddress’ into type: class [Ljava.lang.String;

Caused by: java.lang.ClassCastException: Cannot coerce value ‘myaddress’ into type: class [Ljava.lang.String;  
more  
(I) 16:30:32 Pipeline [name=New Pipeline,version=158] Alarm pipeline started.[/quote]

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [October 5, 2015, 2:46pm UTC](https://forum.inductiveautomation.com/t/script-in-alarm-pipeline/10573/4 "2015-10-05T14:46:25Z")

</div>

The exception is telling you that it’s expecting a String where you are using myaddress, but you are not giving it something it can turn into a string. If you post your declaration of myaddress (sanitized), the line where you are calling system.net.sendEmail, and the version of Ignition you are using, I can help you get that straightened out.

---

<div class="post-metadata">

**Author:** ![flavien](https://avatars.discourse-cdn.com/v4/letter/f/f475e1/32.png) [@flavien](https://forum.inductiveautomation.com/u/flavien)\
**Post date:** [October 6, 2015, 1:16pm UTC](https://forum.inductiveautomation.com/t/script-in-alarm-pipeline/10573/5 "2015-10-06T13:16:18Z")

</div>

My script :

```auto
def handleAlarm(event):

system.net.sendEmail("mail.smtp.fr","alarmtest@smtp.fr","test" ,"test" ,0 ,"fb@mycompany.fr")

```

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [October 6, 2015, 1:49pm UTC](https://forum.inductiveautomation.com/t/script-in-alarm-pipeline/10573/6 "2015-10-06T13:49:37Z")

</div>

The ‘to’ address should be a list, even though it only has one item in it. Try [code]def handleAlarm(event):

system.net.sendEmail(“mail.smtp.fr”,"alarmtest@smtp.fr",“test” ,“test” ,0 ,[“fb@mycompany.fr”])[/code]

---

<div class="post-metadata">

**Author:** ![Pam3636](https://avatars.discourse-cdn.com/v4/letter/p/bc79bd/32.png) [@Pam3636](https://forum.inductiveautomation.com/u/Pam3636)\
**Post date:** [October 7, 2015, 1:47pm UTC](https://forum.inductiveautomation.com/t/script-in-alarm-pipeline/10573/7 "2015-10-07T13:47:52Z")

</div>

Since I fail so badly in scripting, a way to get around this would be:

In the gateway, Configure\>Alarming\>on call roster give each user a separate roster (contact1 and contact2)

In your project create a separate alarm notification pipeline for each contact (CONTACT1 and CONTACT2)

In your tag editor create a new alarm in each tag. Ex: Tag1 Mode: above setpoint, setpoint = 10  
Then your notification active pipeline would be CONTACT 1

So each time your setpoint for that tag went above 10, it would send the notification to the CONTACT1 pipeline Where you can specify an e-mail notification be sent to your contact1 roster.

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [October 7, 2015, 2:01pm UTC](https://forum.inductiveautomation.com/t/script-in-alarm-pipeline/10573/8 "2015-10-07T14:01:26Z")

</div>

In Ignition 7.8, you won’t have to create different pipelines, because the rosters are expressions. (Assuming you’re more comfortable with expressions than scripting… )

---

<div class="post-metadata">

**Author:** ![Pam3636](https://avatars.discourse-cdn.com/v4/letter/p/bc79bd/32.png) [@Pam3636](https://forum.inductiveautomation.com/u/Pam3636)\
**Post date:** [October 7, 2015, 3:08pm UTC](https://forum.inductiveautomation.com/t/script-in-alarm-pipeline/10573/9 "2015-10-07T15:08:14Z")

</div>

I’m still on 7.7, expressions are much more user friendly for me. Looking forward to upgrading. Thanks!

---

<div class="post-metadata">

**Author:** ![flavien](https://avatars.discourse-cdn.com/v4/letter/f/f475e1/32.png) [@flavien](https://forum.inductiveautomation.com/u/flavien)\
**Post date:** [October 13, 2015, 10:17am UTC](https://forum.inductiveautomation.com/t/script-in-alarm-pipeline/10573/10 "2015-10-13T10:17:47Z")

</div>

Hi,

It’s better to put the sendEmail function in a Tag Script Event \> AlarmActive. You can send email to all recipients you want and add your conditions.  
I did it and it works perfectly.
