Community forum

Please note that VisualCron support is not actively monitoring this community forum. Please use our contact page for contacting the VisualCron support directly.


Jake Warner
2017-11-16T00:32:19Z
I have about 40 different jobs. I have figured out how to add in an Email task for a job if something fails, however, I want to avoid doing this manually for each job. Is there a way that I can create failure emails for ALL of my jobs? Essentially, anything that pops up as 'Failed Jobs' in the top of the Visual Cron dashboard... I want an email.

Perhaps this is a feature request. (Check box that any failures send email to a user.)

I appreciate any help or guidance people can provide!
Sponsor
Forum information
thomas
2017-11-16T09:48:25Z
Haven't tested this, but you could try creating a job, that has a VicualCron trigger on failed jobs. Add a task to this job that sends an email, with details from the trigger. This will only give you info that job 'X' has failed. I'm not sure if you can get the actual exception this way

Capture.PNG
thomas
2017-11-16T14:06:10Z
Ok I just tried this on the test server. DON'T try this!

It fired 1 million times. Maybe it fires for historical failures also.
Support
2017-11-16T14:11:25Z
In 8.3.0 you can create a Notification (email for example). And then go to Server settings and set "Default flows". These can be set for either Jobs or Tasks which means that the flow in question will be added for all new Jobs. You also have the option to add it to all existing Jobs.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Jake Warner
2017-11-20T03:21:09Z
Thanks Thomas. Although it fired off 1 million times for you, for me it worked perfectly.
thomas
2017-11-20T09:24:05Z
Ok cool. I assume you are on a newer version than us. We have 8.2.5
vamllp-itadmin
2018-08-31T08:23:55Z
Originally Posted by: thomas 

Haven't tested this, but you could try creating a job, that has a VicualCron trigger on failed jobs. Add a task to this job that sends an email, with details from the trigger. This will only give you info that job 'X' has failed. I'm not sure if you can get the actual exception this way

Capture.PNG



I set this up (v8.3.5) and it works great for me.
Using the {TRIGGER(<job direct id>|LastTrigger|VisualCron.Result.Message)} variable it tells me which job failed. I wonder, however, if anyone has found out a way to populate the notification (mine is email) with variables to show which task(s) failed and their output (error)?

tia
james
jrtwynam
2018-09-07T12:22:36Z
Hi,

I wonder if anyone has had any luck with this? I'm in the process of setting up an email notification for job failures. Some stuff is easy to include (job name, group, description, exit code, and result), but what I'd also like to include is a list of all the tasks in the job, along with the result of each task and the error message from the one that failed.

Thanks.
jrtwynam
2018-10-17T17:52:21Z
Hi,

I'm still trying to figure out how to send an email when a job fails, that includes a complete list of the job steps and their results. I know how to send an email when a job fails, and include the job's status, but not the tasks within the job.

What I had thought about doing was creating another job called "Error Handler", and in the flow for On Error of all other jobs I'd have it run this job instead of sending a notification email. This job would run a Job Report, but I ran into a couple of issues with that:


  1. I can't seem to find a way to pass the Job Report task a Job ID - there's just a list of jobs in the settings, and I have to check one (or more) of them off.
  2. The default job report is ugly and not really formatted in a user-friendly view. E.g. when listing the tasks for a job, it's not necessary to repeat the headers for the task attributes for each task, they should only be listed once at the top of the task list. So, I was planning to construct my own HTML file for this by running the job report but outputting it to the task's output in CSV format. Unfortunately, the resulting text isn't formatted in CSV format, and I don't see any way to specify things like column separator, text qualifier, etc, like there is in pretty much every other task that allows multi-line output. The output looks like this:
    Update New Max Values;;10/17/2018 12:08:10 PM;00:00:19.1;0;Start the Log Entry for the Current Run;Write file;Success;00:00:00.3;Set Report Export File Name;Set Job Variable;Success;00:00:00.2;Get List of Files in Working Folder;List file(s);Success;00:00:00.1;Log the Current File Name;Write file;Success;00:00:00.2;Convert Excel File to CSV File;Excel - Convert;Success;00:00:00.2;Read CSV File;Read file;Success;00:00:00.2;Write HTML Header to Report File;Write file;Success;00:00:00.3;Get Current Location Max Qty;SQL;Success;00:00:00.3;Set Style;Set Job Variable;Success;00:00:00.2;Set Description;Set Job Variable;Success;00:00:00.2;Set Old Max;Set Job Variable;Success;00:00:00.2;Log the Current Location;Write file;Success;00:00:00.3;Update the Max Qty in the Database;SQL;Success;00:00:00.1;Write HTML Detail to Report File;Write file;Success;00:00:00.5;Write HTML Footer to Report File;Write file;Success;00:00:00.4;Read HTML Report File;Read file;Success;00:00:00.2;Move HTML Report File to Archive Folder;Copy files;Success;00:00:00.2;Move Excel File to Processed Folder;Copy files;Success;00:00:00.1;Delete CSV File;Delete file;Success;00:00:00.1;Set Email To;Set Job Variable;Success;00:00:00.1;Set Email CC;Set Job Variable;Success;00:00:00.2;Set Email Subject;Set Job Variable;Success;00:00:00.1;Email;Email;Success;00:00:03.2;End the Log Entry for the Current Run;Write file;Success;00:00:00.2



Does anyone have any thoughts on how I can do this?

Thanks.
thomas
2018-10-18T09:49:17Z
I don't think there is any nice way of doing what you are trying to do, without using the api. You would have to write some code using the api wrapped in .net. On error, you call this library and pass in the id of the failing job. This library then finds all the tasks and results and produces anything you like.
jrtwynam
2018-10-23T17:05:06Z
Thanks for the reply - that sounds a bit complicated, since my .net coding is basically non-existent. I think what you're suggesting is writing a DLL file that takes a job ID as a parameter, and pulls whatever info I want from the VC database using API calls., and returns those results in its output in some format that can be looped through in order to construct some HTML or some other visually-appealing representation of the data that can be inserted into an email. This brings me to a couple of other questions:


  1. Could this also be accomplished with a .NET task as opposed to writing a full DLL? Or maybe this is actually what you meant and I misinterpreted it.
  2. What kind of database does VC use? Could I not just create a new connection to that database and run an SQL against it? I'm actually surprised that there isn't a built-in task to do this with a read-only connection - I can understand why they wouldn't want people to run update statements against it, but being able to run a simple query against it would allow for more functionality such as this.

thomas
2018-10-24T10:17:00Z
That's correct. That is what I think you have to do to achieve what you want

To answer your other questions:

1) I don't know if it is possible with a .NET task. I see you can add reference to the VisualCron dll's, so maybe. Making your own class library is a lot easier than trying to do it in a .NET task, so I personally wouldn't go that way

2)Support will have to answer this, but I can try to guess: If they expose the db to users, you could potentially read from the db while VC is writing to the same db, and cause a deadlock (depending on how the db they use handle these things). By exposing the functionality through an api, they can take care of this scenario in the background, without you having to deal with it.

Something else you need to think about is this: If you have a job that calls another job, and the child job fails, what info do you want?
jrtwynam
2018-10-24T12:31:59Z
Maybe I'll fiddle around with this more when time permits. Admittedly, it's not a hugely important requirement right now because I'm the only one on my team that accesses VC, so if something fails, I can simply log in to see why. I was surprised to find that there's no "easy" way to do this though - given all of the zillions of other things that VC makes easy, why not this? 🙂 Maybe this is an idea for an enhancement - add a new task type under "internal" called "get job tasks" or something, which would take a job name or ID as a parameter, allow the user to specify what column(s) they want, and return the data in the same type of format that you can specify with an SQL task (i.e. text qualifier, field delimiter, etc).

On a related note, I went digging through the VC folder yesterday trying to figure out where the DB file is so I could try creating a connection to it. I'm not sure that there is an actual DB file - I found an XML file that seemed to contain all the settings for all my jobs, which was getting updated every minute (because I have a job that's scheduled to run every minute). It might be possible to read that file using a combination of VC's XML tasks to accomplish what I want.
thomas
2018-10-24T13:11:31Z
I agree it would be a useful feature. If you read from the settings xml, make sure you don't create a lock on the file. Seems scary to me. I would go the api route, you can find samples under C:\Program Files (x86)\VisualCron\API\samples
jrtwynam
2018-11-02T18:59:10Z
I made some progress with this using the Web API as well as some HTML tasks.

First, I created a job that has a Job ID as a job variable. That job is configured like this:
Job Tasks.jpg

So it uses the Web API to get an authorization token, which it subsequently uses to get the job info and tasks within the job. It then loops through the results and produces some HTML, which gets emailed to a specified address. The email looks like this:
Email File.jpg

I'm still working on cleaning up the format of the HTML and pulling things like the Task Result so that it's obvious which task caused the job to fail, but so far I don't see anything in the API documentation that tells how to pull the result. Anyway, my thought was that in the Flow section of each other job, I could have an On Error event that runs this task, something like this:
Job Flow.jpg

I've run into an issue here though - I don't see a way to pass the job ID as a parameter to this job.
thomas
2018-11-02T19:57:29Z
Seems nice what you have done! Can't you just pass the jobname, and get the id from the name in the api? Even though the name can change over time, it will be correct at runtime, except in extreme edge cases..

jrtwynam
2018-11-05T00:14:01Z
I don't see a way to pass any variables to a job that's run in the Flow section. Besides, I'd rather not pass the job name, because I'm not sure how that would react if I had two jobs with the same name.

I had thought of having the error job somehow reference the previous task (or job), but I'm not sure how that would work. In theory the only possible scenario where it would work fine would be if there was only ever one job running at a time. If I have 30 jobs that run at a time, and one of them fails, I'm not sure that the error job would be guaranteed that the "previous" job was the one that errored out.

Although, as I'm typing this, I wonder if the error job would have something in the variables under Triggers. I.e. the error job would have been triggered by another job, so maybe I can get the job ID from there somehow.
Scroll to Top