Jump to content
Joe Lusk

Email the initiating tech script stats and results

Recommended Posts

I added this little line and it has helped me tremendously. It allows the script to automatically email whoever kicked it off, not just a static email address. Since we have 30+ techs and close to 6000 agents, this is very useful.

Function: Variable Set 

Set Type: SQL Query

Parameter: select email from users where name ='@LTRUNBYUSER@'

Variable Name: initiatoremail

Then I use the send email function to email the @initiatoremail@ that the script has begun; including @script name@ variable (which I set) %clientname% and %computername%. Then again at various failure points, including other variables that provide a description of where it failed in the script.  Lastly it sends an email upon success.

 

This way when I kick the script off for a bunch of computers, I can track the state of each of them easily.  I set up rules in my email client to sort them into folders by success/ failure etc.

 

Maybe there was an easier way to do this, but I never found it. 🙂

 

 

Share this post


Link to post
Share on other sites

Easier way: Use Darrens script

Take a look around LTG and find some of the scripts posted by Darrenwhite. One of his is a script to send an email. By default it sends it to the tech who executed the script.

 

The question is, why on earth LT don't make scripts like this available as standard.

 

Share this post


Link to post
Share on other sites
11 hours ago, imurphy said:

Easier way: Use Darrens script

Take a look around LTG and find some of the scripts posted by Darrenwhite. One of his is a script to send an email. By default it sends it to the tech who executed the script.

 

The question is, why on earth LT don't make scripts like this available as standard.

 

Do you happen to have a link to the script in question? I've not been able to find it.

Share this post


Link to post
Share on other sites

I have looked and I can't find it either.

Though I am not sure how much easier it can be then 2 lines; 1 to pull the email address, 2 to send the email 🙂

Share this post


Link to post
Share on other sites
1 hour ago, Joe Lusk said:

I have looked and I can't find it either.

Though I am not sure how much easier it can be then 2 lines; 1 to pull the email address, 2 to send the email 🙂

I only ask because i'm running into an issue where running the sql query you posted above returns a value of -9999, and CW support doesn't know why.

I also tried against my own username, and it returns the same.

Share this post


Link to post
Share on other sites
On 8/17/2018 at 1:21 PM, jhanks said:

I only ask because i'm running into an issue where running the sql query you posted above returns a value of -9999, and CW support doesn't know why.

I also tried against my own username, and it returns the same.

Throw a Script Log: “Run By: @LTRunByUser@“ into your script. -9999 is what is returned for a null result. Assuming you didn’t break something weird in the query the problem is that the variable isn’t set. This occurs when you are running in the debugger (oops) or when your table triggers are broken (can occur if the table is dropped and added). Have support help you reload your triggers (dbasetriggers.sql in the setup folder?) and you should start seeing this variable when running scripts. I guess another reason could be that no email address has been entered for the user, but I assume that was already ruled out  

Yes the two line version is arguably simpler than calling a function script like the one I use. But the function script can include standard text blocks and formatting in your email, and as you improve the function (say by including a logo or something) all scripts using the function are automatically “improved”.  Anytime I have identical code blocks in multiple scripts I consider if a function script would be appropriate. Unless the solution is completely perfect, I assume  that I will probably improve it someday. In that case I try to use a function script so that the improvement can benefit dozens of scripts automatically. Function scripts also enforce consistency even when there are multiple script writers in your company. 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

@DarrenWhite99 I agree and prefer re-usable function scripts wherever possible. I am relatively new to Labtech scripting so I may have gone over some already trodden ground. That being said, this is part of a bigger function script that I have made and add to all of my scripts. I just felt the variable set was the most useful part for others, and since I couldn't find it anywhere else I thought someone else might find it useful too.

Thanks for all of your contributions here, I have found them invaluable to my crash course in Labtech(Automate) scripting.

 

  • Thanks 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×