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
On 8/15/2018 at 3:37 PM, Joe Lusk said:

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. 🙂

 

 

Have you done anything with pulling the name of the script from the database to be able to store the value of it inside a variable for the script name? I am trying to do something similar to this except for it gets the name of the script and sets it equal to that value when the script is ran 

Share this post


Link to post
Share on other sites

Have you done anything with pulling the name of the script from the database to be able to store the value of it inside a variable for the script name? I am trying to do something similar to this except for it gets the name of the script and sets it equal to that value when the script is ran 

Share this post


Link to post
Share on other sites
On 8/20/2018 at 12:50 AM, DarrenWhite99 said:

...
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”. 

As a real life example: Some time ago I updated my “Send email to Technician” script to call a second script: “Send Slack message”.  The recipients emails are already worked out by the Send Email script, the message body, computer name, client, etc. are all known. So it does a lookup in Slack for a matching email address and sends a direct message with the script results. The Slack message is specially reformatted and includes Client, Location, and Agent links to Automate in the web. 

So because scripts are all using the common function script to send email notifications, all scripts gained Slack notification functionality automatically. 

Sample Slack (mobile) message:

67F72EF8-E1D6-4B90-B8BD-5B396C4F60A4.jpeg

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...