Send mail when the Jobs fail

Hi,

We have a couple of jobs that are scheduled daily.
Is there any way, we can select options in the management console such that if the jobs fail, a notice is sent to the mail addresses.

I could do it for the scheduled reports in BO CMC.

Thanks in advance.


rookie86 :india: (BOB member since 2009-09-11)

I think it’s not possible via management console …
But you can add ā€œtry …catchā€ blocks in your jobs to send email if jobs fail …


Toons :fr: (BOB member since 2009-04-14)

Toon is right. But there is a workaround.

In the job you want to monitor put a TRY transform before the first workflow and put a CATCH transform after the last workflow (or place them across which workflows ever you want to monitor). In the catch, set it to catch all exceptions (or whatever you want to catch).

Within the flow area of the catch, add a workflow or dataflow and within this add a script that contains the smtp_to() function. You will need to configure your DI server to be able to send smtp mail server with this method (should be information available in the supporting doucmentation or on this site). You can use other DI functions to include additional information in the email too.

If you want to toggle whether these are emails are generated from the management console this requires something extra again!

Add a new variable to the original job (e.g. called ā€˜EMAIL_FLAG’)
Have this variable set by retrieving the value of a flag held in a database table (e.g. table name ā€˜BODI_VARIABLES’)
In the original job, alter the CATCH email script to only send an email if this flag is True.
Create a two new jobs that will either set or unset this EMAIL_FLAG.
You can then run this new job from the management console in order to email (or not) if the original job fails.

Alternatively, create the job variable (ā€˜EMAIL FLAG’), alter the email script to use this flag and when scheduling the job in the management console, create two identical schedules except for one the value is manually set to TRUE (or 1) and the other FALSE (or 0). Active and deactivate as required.

Hope these ideas help!


Darth Services :uk: (BOB member since 2007-11-20)

Thanks Darth and Toon for the suggestions.

I have added the try-catch blocks and smtp_to function in my job. But as Darth said, my admin has to do the necessary configurations in the Job server for it to send mails.


rookie86 :india: (BOB member since 2009-09-11)

Hey guys,

Being implemented the mail functionality using mail_to function, I am able to send mails when the job fails.

But the only concern is, the admin console is displaying the job’s status in Green color when it fails. Usually without having the try catch blocks, if the job fail, the status will be displayed in red cross.

But here i am not getting like that. Should I change some setting such that even when i use the try catch blocks, the job’s status goes to red color when it fails?

Thanks in advance.


rookie86 :india: (BOB member since 2009-09-11)

In the catch block call the raise_exception() function to finally error out the job.


Werner Daehn :de: (BOB member since 2004-12-17)

Hi,

I too have a similar issue. The job is in green status due to try/catch block. This is OK for me.

I am using the AL_HISTORY to list the aborted jobs or the jobs which had warnings based on the fields USAGE and HAS_ERROR.

The job which is in green status (inspite of warnings and errors in the error log) has HAS_ERROR = 0 in AL_HISTORY table. How to list that job too?

Regards,
Sameer


sameer81 :new_zealand: (BOB member since 2007-09-15)