Today, I wanted to share with you a few automation best practices. The first one is simply to get a confirmation of success or information if anything failed. In automation script, this is done by email. For success, just add an email activity to the end of your script. I have one here. You can, in this email, add a report that you've generated through the script, or you can just simply say that the script was done successfully.
To set up an exception email, go to the Settings activity, which is this one right here, and click on it so the Designer shows. And you're going to see down here an option that says, Send email when an error occurs and also Attach log file to the email. I suggest that you choose both of these. And then you would click on the Compose Email and fill out the From and To and the email server settings.
Between these two emails of success or error information, you're going to get the confidence that you need that your scripts are running successfully. If you find that you're not getting either one of these emails from your script, you can then go to the Windows scheduler. And there's a way to configure a Windows task to email you if it fails to start.
There's documentation on the internet on how to do this. Basically it's defining a trigger based off of a failed Windows scheduler event. I won't go into that detail here, but I recommend you do this only when you're having difficulties with the script running at all, which usually is not the common case.
The legibility of scripts can also be an issue. So to make a script more legible, you can explicitly give the name of an activity here on the Info tab a more meaningful name, or you can add here into the description some information about the basic activity. When you hover over the activity, you're going to see that in the hint there, Select address to report with some additional annotation that I put.
I like to actually use this Log Comment activity. And this gives me a free form area where I can write as much as I want about what I'm doing in that area of the script or the whole script itself. I can also put the author and any revision date. So there's no limit to the amount of information that I can annotate into this particular activity.
For larger scripts, I like to use the group activity. And this group activity allows me to put one or more activities inside of it, and then I can collapse it. And this gives me the ability to manage larger scripts in a smaller space. You can also use this parallel activity, which makes the activities run horizontal. But again, all of this can be collapsed into a much more manageable space.
I also like to use the run automation script activity. So here we're using our own code over and over again. So you can add-- running a completely written automation script. And you can also control the sequence of execution. In this case, this script will run completely, and at the moment it is done, it will open up and run the next script. So they're very tightly scheduled in sequence.
Now management of automation scripts is also very important. And using a source control system would be best. But you know a shared drive is just as fine too. I had a shared drive here that I was going to show you where I actually have some of my files. Let's take a look. Here's a lot that I use here and I share with my team. But always make sure you have backups of your scripts. You never know when you're going to actually need to copy.
But in addition to this, you can use a project manager to help you group together certain types of scripts and sort your files out. So the project manager can be used to organize scripts as well as you can open up the scripts from here or actually execute them from this menu.
Once you start using automation script, it's going to be important to keep track of what scripts you have and when they're running. The job manager helps you create the scripts, but it also shows you what's scheduled. There's an action here. It says, Export to Excel. And I think keeping in Excel a list of your jobs when they're scheduled is a very handy thing to have, particularly if you're moving them to another server. So these are the things that I've found that make building and maintaining scripts easier for myself and for my team.