Scripting - Best Practices and Tips

We encourage all of our Resellers that have access to scripting to give it a try. We suggest that you use your demo account so that you are not actually affecting any live punch data for one of your clients.

You will find that our knowledge base has a lot of information and test examples for scripting that you can easily replicate and customize to fit your needs.

Scripting Course

If you have not taken our scripting course, it is a great starting point. Iur Beginning Scripting Course is a one-on-one opportunity to be shown the basics of scripting by one of support techs. It can be given for either TimeWorks or TimeWorksPlus.

If you are interested in the course, please submit a ticket through our Support Center requesting this service.

Scripting Webinar

Another resource would be this webinar that was conducted by our support techs and is available to view online. It does requires Adobe Flash.

Can a script be reversed?

Technically, yes. All a script does is changes the way the punch information is reflected on the time card, reports, and the export. The original punch information is not altered and by removing the script, the data will be reverted back to how it appeared originally.

There is an exception howeverFinalized Pay Periods will not be affected by script changes, both in adding or removing a script. So, if you had a script in place then finalized a pay period, removing that script will not alter the finalized pay period whatsoever. If you unfinalize the pay period, then the changes you made will take effect.

Best Practices

It is a good idea to:
  • Back up your scripting by saving it using Notepad. MS Word is not advisable as it changes the fonts on punctuation's and can affect your script working properly.
  • Use your demo account for testing purposes. You may not want to test your scripting on live data. When making changes it is especially important to keep a backup.
  • Changing scripts will not affect pay periods that have been Finalized. If you are testing a script and nothing is changing it could be because the punches are frozen. You will need to unfreeze punches before conducting your tests.

Commenting Scripts - Deactivating a Line of Scripts without Deleting Scripts

It is possible to disable all or any portion of a script, without having to delete or remove it. It is also possible to make notes in your scripts that can assist in identifying the purpose of the script or even to help understand where to make adjustments when a change is necessary.

This section covers commenting scripts, which is a term for inserting lines in a script that actually do not have any effect on the actual script. Commenting can also be used to deactivate a line or multiple lines of script without deleting the script entirely from the box. This can be very useful when trying to determine where mistakes may be happening in your script.

Deactivate One Line of a Script
Place "//" at the beginning of the line you wish to deactivate. This is a good method if you only have one or two consecutive lines to deactivate. Here is an example of a script that has one deactivated line:

     if (category = "Regular")
     {
     payrate = payrate1;
     //payrate = payrate2;    <--- this line will be ignored
     }


Deactivate Several Lines of a Script
Place "/*" at the beginning and "*/" at the end of the part of the script you want to deactivate. Here is an example of a script that has a been deactivated:

     /*

     if (category = "Regular") <--- this line will be ignored
     {                                   <--- this line will be ignored
     payrate = payrate1;       <--- this line will be ignored
     }                                   <--- this line will be ignored

     */



Here is an example of how to use this to deactivate a portion of the a script, while leaving the other part active (top part):

     if (category = "Regular") {
          payrate = payrate;
     }
     /*
     if (category = "Regular") <--- this line will be ignored
     {                                   <--- this line will be ignored
     payrate = payrate1;       <--- this line will be ignored
     }                                   <--- this line will be ignored
     */


Add Comments to a Script
It is possible to use these deactivation symbols to add comments or descriptions to a script. This can be usefull if you ever need to come back to the script to make adjustments. Here is an example of a script with added comments:

     /*
     This script is for Bill       <--- this line will be ignored
     he gets a pay differential <--- this line will be ignored
     if he works over 4 hours   <--- this line will be ignored
     */
     if (home1 = "Bill" and hours > 4)
     {
     //the differential was changed to $1.50 by Amy in DEC 2010  <--- this line will be ignored
     payrate = payrate + 1.50; 
     }


Note: it is possible to disable a portion of a script that the remaining portion depends on to run correctly.

Did you find this article helpful?