# How to send Email when Scheduled Task Errors Out

**URL:** <https://www.epiusers.help/t/how-to-send-email-when-scheduled-task-errors-out/43498>\
**Category:** Epicor ERP 10\
**Tags:** e10\
**Created:** [March 19, 2018, 8:14pm UTC](https://www.epiusers.help/t/how-to-send-email-when-scheduled-task-errors-out/43498 "2018-03-19T20:14:06Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![utaylor](https://www.epiusers.help/user_avatar/www.epiusers.help/utaylor/32/64664_2.png) [@utaylor](https://www.epiusers.help/u/utaylor)\
**Post date:** [March 19, 2018, 8:14pm UTC](https://www.epiusers.help/t/how-to-send-email-when-scheduled-task-errors-out/43498/1 "2018-03-19T20:14:06Z")

</div>

Hello All,

Does anyone know how to send a notification that a scheduled task has failed?

Respectfully,

Utah

---

<div class="post-metadata">

**Author:** ![josecgomez](https://www.epiusers.help/user_avatar/www.epiusers.help/josecgomez/32/55731_2.png) [@josecgomez](https://www.epiusers.help/u/josecgomez)\
**Post date:** [March 20, 2018, 1:09am UTC](https://www.epiusers.help/t/how-to-send-email-when-scheduled-task-errors-out/43498/2 "2018-03-20T01:09:53Z")

</div>

Data Directive in the SysTask table perhaps?

---

<div class="post-metadata">

**Author:** ![utaylor](https://www.epiusers.help/user_avatar/www.epiusers.help/utaylor/32/64664_2.png) [@utaylor](https://www.epiusers.help/u/utaylor)\
**Post date:** [March 20, 2018, 11:34am UTC](https://www.epiusers.help/t/how-to-send-email-when-scheduled-task-errors-out/43498/3 "2018-03-20T11:34:46Z")

</div>

How easy is that! Kicking myself over here! 😑

---

<div class="post-metadata">

**Author:** ![utaylor](https://www.epiusers.help/user_avatar/www.epiusers.help/utaylor/32/64664_2.png) [@utaylor](https://www.epiusers.help/u/utaylor)\
**Post date:** [March 20, 2018, 11:57am UTC](https://www.epiusers.help/t/how-to-send-email-when-scheduled-task-errors-out/43498/4 "2018-03-20T11:57:58Z")

</div>

What do you think about enabling data directives for that table though? Would it slow other tasks down?

---

<div class="post-metadata">

**Author:** ![josecgomez](https://www.epiusers.help/user_avatar/www.epiusers.help/josecgomez/32/55731_2.png) [@josecgomez](https://www.epiusers.help/u/josecgomez)\
**Post date:** [March 20, 2018, 12:19pm UTC](https://www.epiusers.help/t/how-to-send-email-when-scheduled-task-errors-out/43498/5 "2018-03-20T12:19:44Z")

</div>

Should be fine just do it async

---

<div class="post-metadata">

**Author:** ![utaylor](https://www.epiusers.help/user_avatar/www.epiusers.help/utaylor/32/64664_2.png) [@utaylor](https://www.epiusers.help/u/utaylor)\
**Post date:** [March 20, 2018, 12:36pm UTC](https://www.epiusers.help/t/how-to-send-email-when-scheduled-task-errors-out/43498/6 "2018-03-20T12:36:21Z")

</div>

Would you do an in-transaction or standard data directive? It seems that the temporary table ttSysTask only shows tasks in a PENDING status and I need the ERROR status which is after the fact…

---

<div class="post-metadata">

**Author:** ![josecgomez](https://www.epiusers.help/user_avatar/www.epiusers.help/josecgomez/32/55731_2.png) [@josecgomez](https://www.epiusers.help/u/josecgomez)\
**Post date:** [March 20, 2018, 12:37pm UTC](https://www.epiusers.help/t/how-to-send-email-when-scheduled-task-errors-out/43498/7 "2018-03-20T12:37:37Z")

</div>

Standard for emailing.

---

<div class="post-metadata">

**Author:** ![utaylor](https://www.epiusers.help/user_avatar/www.epiusers.help/utaylor/32/64664_2.png) [@utaylor](https://www.epiusers.help/u/utaylor)\
**Post date:** [March 20, 2018, 12:40pm UTC](https://www.epiusers.help/t/how-to-send-email-when-scheduled-task-errors-out/43498/8 "2018-03-20T12:40:31Z")

</div>

That part makes sense, but how would you get the status of a completed task?

It seems the ttSysTask table only has PENDING tasks, would I then need to LINQ into the Db.SysTask table to find the final status of the task ?

---

<div class="post-metadata">

**Author:** ![josecgomez](https://www.epiusers.help/user_avatar/www.epiusers.help/josecgomez/32/55731_2.png) [@josecgomez](https://www.epiusers.help/u/josecgomez)\
**Post date:** [March 20, 2018, 12:41pm UTC](https://www.epiusers.help/t/how-to-send-email-when-scheduled-task-errors-out/43498/9 "2018-03-20T12:41:15Z")

</div>

When the task is updated to ERROR it should go through the Data Trigger… (I hope)? Is that not the case?

---

<div class="post-metadata">

**Author:** ![utaylor](https://www.epiusers.help/user_avatar/www.epiusers.help/utaylor/32/64664_2.png) [@utaylor](https://www.epiusers.help/u/utaylor)\
**Post date:** [March 20, 2018, 12:51pm UTC](https://www.epiusers.help/t/how-to-send-email-when-scheduled-task-errors-out/43498/10 "2018-03-20T12:51:25Z")

</div>

It doesn’t seem to be the case. Even when I query the Db.SysTask table it still says pending.

---

<div class="post-metadata">

**Author:** ![utaylor](https://www.epiusers.help/user_avatar/www.epiusers.help/utaylor/32/64664_2.png) [@utaylor](https://www.epiusers.help/u/utaylor)\
**Post date:** [March 20, 2018, 12:53pm UTC](https://www.epiusers.help/t/how-to-send-email-when-scheduled-task-errors-out/43498/11 "2018-03-20T12:53:47Z")

</div>

Maybe should do a method directive? Do you see any downfalls to that?

---

<div class="post-metadata">

**Author:** ![tkoch](https://www.epiusers.help/letter_avatar_proxy/v4/letter/t/439d5e/32.png) [@tkoch](https://www.epiusers.help/u/tkoch)\
**Post date:** [March 20, 2018, 1:00pm UTC](https://www.epiusers.help/t/how-to-send-email-when-scheduled-task-errors-out/43498/12 "2018-03-20T13:00:49Z")

</div>

Pending means something is up with your Task Agent and the report/process has not been run yet.

The TaskStatus column with get changed to ERROR if the report/process fails.

---

<div class="post-metadata">

**Author:** ![utaylor](https://www.epiusers.help/user_avatar/www.epiusers.help/utaylor/32/64664_2.png) [@utaylor](https://www.epiusers.help/u/utaylor)\
**Post date:** [March 20, 2018, 1:01pm UTC](https://www.epiusers.help/t/how-to-send-email-when-scheduled-task-errors-out/43498/13 "2018-03-20T13:01:32Z")

</div>

Thanks, yeah I am not concerned with the pending status, I would just like the final status after it has been ran.

Respectfully,

Utah

---

<div class="post-metadata">

**Author:** ![josecgomez](https://www.epiusers.help/user_avatar/www.epiusers.help/josecgomez/32/55731_2.png) [@josecgomez](https://www.epiusers.help/u/josecgomez)\
**Post date:** [March 20, 2018, 1:10pm UTC](https://www.epiusers.help/t/how-to-send-email-when-scheduled-task-errors-out/43498/14 "2018-03-20T13:10:17Z")

</div>

There is no method directive for this.

---

<div class="post-metadata">

**Author:** ![utaylor](https://www.epiusers.help/user_avatar/www.epiusers.help/utaylor/32/64664_2.png) [@utaylor](https://www.epiusers.help/u/utaylor)\
**Post date:** [March 20, 2018, 1:16pm UTC](https://www.epiusers.help/t/how-to-send-email-when-scheduled-task-errors-out/43498/15 "2018-03-20T13:16:16Z")

</div>

![systask%20method](https://epiusers.help/uploads/default/original/2X/8/821c5d62492d556ee441ece403ba8ce58ef2e58e.JPG)

This is the update method. Do you see anything wrong with this?

---

<div class="post-metadata">

**Author:** ![josecgomez](https://www.epiusers.help/user_avatar/www.epiusers.help/josecgomez/32/55731_2.png) [@josecgomez](https://www.epiusers.help/u/josecgomez)\
**Post date:** [March 20, 2018, 1:16pm UTC](https://www.epiusers.help/t/how-to-send-email-when-scheduled-task-errors-out/43498/16 "2018-03-20T13:16:47Z")

</div>

It likely won’t get called. I don’t think they use that specific BO to update the tasks… But give it a shot.

---

<div class="post-metadata">

**Author:** ![utaylor](https://www.epiusers.help/user_avatar/www.epiusers.help/utaylor/32/64664_2.png) [@utaylor](https://www.epiusers.help/u/utaylor)\
**Post date:** [March 20, 2018, 1:29pm UTC](https://www.epiusers.help/t/how-to-send-email-when-scheduled-task-errors-out/43498/17 "2018-03-20T13:29:51Z")

</div>

![settaskstatus](https://epiusers.help/uploads/default/original/2X/c/c2594bbe8b7d5dcd411b683b0495317ebe44f569.JPG)

I found one method under the SysTask BO that updates the task status for a pending task. They were quite detailed when they named this method.

---

<div class="post-metadata">

**Author:** ![utaylor](https://www.epiusers.help/user_avatar/www.epiusers.help/utaylor/32/64664_2.png) [@utaylor](https://www.epiusers.help/u/utaylor)\
**Post date:** [March 20, 2018, 1:38pm UTC](https://www.epiusers.help/t/how-to-send-email-when-scheduled-task-errors-out/43498/18 "2018-03-20T13:38:52Z")

</div>

@josecgomez I can use that method’s variable (sysTaskNum) to retrieve the matching row from the Db.SysTask table which allows me to filter for the scheduled task that I am looking for using SysTask.AgentSchedNum == xMyAgentSchedNum.

Would you suggest running a post processing method directive as asynchronous as well?

Would you suggest using this method directive in the first place?

---

<div class="post-metadata">

**Author:** ![josecgomez](https://www.epiusers.help/user_avatar/www.epiusers.help/josecgomez/32/55731_2.png) [@josecgomez](https://www.epiusers.help/u/josecgomez)\
**Post date:** [March 20, 2018, 1:39pm UTC](https://www.epiusers.help/t/how-to-send-email-when-scheduled-task-errors-out/43498/19 "2018-03-20T13:39:28Z")

</div>

If that Method is actually being called then you are golden, post processing async is your best friend.

---

<div class="post-metadata">

**Author:** ![utaylor](https://www.epiusers.help/user_avatar/www.epiusers.help/utaylor/32/64664_2.png) [@utaylor](https://www.epiusers.help/u/utaylor)\
**Post date:** [March 20, 2018, 1:42pm UTC](https://www.epiusers.help/t/how-to-send-email-when-scheduled-task-errors-out/43498/20 "2018-03-20T13:42:32Z")

</div>

Thanks a lot for your help this morning. ✌ 👍

[Next page](https://www.epiusers.help/t/how-to-send-email-when-scheduled-task-errors-out/43498.md?page=2)
