Scripting Rule Boxes

TimeWorksPlus Script Boxes

In TimeWorksPlus, there are multiple areas where you can enter a script. We refer to these as Script Boxes and each of them are their own rule in the Processing Rules page. All Script Boxes, with the exception of the OTThreshold Script, are found in the Scripting rule category. The OTThreshold script box is found in the Overtime rule category.
 
The purpose of the multiple boxes is to ensure that the scripts run in a logical order. For instance, if your client has both a Rounding script and an Overtime script, you would not want to run the overtime script before the rounding was run, otherwise, the overtime totals would not be accurate.
 
The item to keep in mind here is a script runs through the time card, row by row, checking the conditions of the script against the data of the time card and executing the commands from the script. So a script runs through the time card from the first day on the time card to the last day, and on each row where there is a punchset, it will execute each of these script boxes, in sequence.

The Sequence of Script Boxes
  1. Round
  2. Script
  3. Split
  4. ReportingDate
  5. AddEntry
  6. SplitPostReportingDate
  7. Shift
  8. PayRate
  9. AccrueUp
  10. AccrueDown
  11. OTThreshold

This handout will step through each scripting box in the order in which the time card reads the script. It will explain the intended purpose of the script box as well as list scripting keywords and methods that are and are not available to be used in the respective box.

Round Script

This script runs first on the time card. Its primary purpose is to apply a rounding rule that cannot be accommodated by any of our predefined rounding rules. For example, if a rounding rule only applies to a certain department or to the first and last punches of the day, this would be the box to use.
 

Useful Keywords Available

  • Employee Setup fields (any employee.xxxxx field)
  • Clock prompt field names
  • round
  • roundin
  • roundout
  • roundends
  • intime
  • outtime
  • touches
  • category
  • weekday

Keywords Unavailable

  • reportingdate object (any keyword starting with reportingdate)
  • payrate
  • shift
  • accruals keywords
  • overtime keywords (ot1threshold, ot2threshold, etc.)

Script

This script is commonly used for reading clock prompt information and either changing a clock prompt or populating a new clock prompt.
 

Useful Keywords Available

  • Employee Setup fields (any employee.xxxxx field)
  • Clock prompt field names
  • hours
  • intime
  • outtime
  • touches
  • category
  • weekday
  • cdate & ctime
Keywords Unavailable
  • reportingdate object (any keyword starting with reportingdate)
  • payrate
  • shift
  • accruals keywords
  • overtime keywords (ot1threshold, ot2threshold, etc.)

Split

The split script is commonly used for splitting a punchset for applying shift differentials or rate premiums. Generally, the split is scripted in this box and the shift or premium is scripted in a later box.
 
Useful Keywords Available
  • Split
  • Employee Setup fields (any employee.xxxxx field)
  • Clock prompt field names
  • hours
  • intime
  • outtime
  • touches
  • category
  • weekday
  • cdate & ctime

Keywords Unavailable

  • reportingdate object (any keyword starting with reportingdate)
  • payrate
  • shift
  • accruals keywords
  • overtime keywords (ot1threshold, ot2threshold, etc.)

Reporting Date Script

When a punchset spans midnight, by default, the hours are reported on the day of the in punch. With the Reporting Date script, you can set rules that change the day on which the hours are reported. In some cases, you may be able to do this with the Yesterday or Today rule, but the ReportingDate Script provides options for more advanced application of this rule. For instance, you can apply it to certain departments, certain days or even if the punchset is a certain length.

Useful Keywords Available
  • Employee Setup fields (any employee.xxxxx field)
  • Clock prompt field names
  • yesterday(0)
  • tomorrow(0)
  • hours
  • intime
  • outtime
  • touches
  • weekday
  • cdate & ctime

Keywords Unavailable

  • reportingdate object (any keyword starting with reportingdate)
  • payrate
  • shift
  • accruals keywords
  • overtime keywords (ot1threshold, ot2threshold, etc.)

AddEntry Script

This scripting rule can add a new row on a day with either an hours or pay item. It cannot be used to add in and out punches. It adds this row by using the addentry keyword.

The addentry method takes three arguments in the following format:

addentry("type", amount, "category");

"type" would be either an "hours" or "amount" entry.
You do need the "" around the type and category.

So if you wanted to auto add entries Monday through Friday in the amount of 8 hours, you would use the following:

if("MTWRF" contains reportingdate.weekday){
addentry("hours", 8, "Regular");
}


If the client were to want to auto pay $50 every pay period, you would write the following:

if(reportingdate.date = reportingdate.payperiodend){
addentry("amount", 50, "Bonus");
}


The following keywords can be used in this script box.
  • reportingdate.date
  • reportingdate.totalhours
  • reportingdate.isholiday
  • reportingdate.hourstodate
  • reportingdate.depthours
  • reportingdate.totalday (note: Using this you will want to set the value for your "totalday" under ReportingDateScript).
The following keywords cannot be used in this script box.
  • intime
  • outtime
  • hours
  • category
  • addalert
  • clock prompt field names
  • minutesout / minutestil
  • touches
  • hourstopunch

 

Split Post Reporting Date Script

This is the second box where you can split a punchset for the purpose of shift differentials or premiums. However, the way in which this differs from the Split script is that this script can account for different reportingdate keywords. For instance, you can apply a split in the case of a holiday or after a yesterday rule has run. This box is commonly used for the purpose of splitting the last second of a punchset for adding holiday hours or splitting at the moment an employee reaches overtime.
 

Useful Keywords Available

  • Employee Setup fields (any employee.xxxxx field)
  • Clock prompt field names
  • reportingdate object
  • hours
  • intime
  • outtime
  • touches
  • weekday

Keywords Unavailable

  • yesterday(0)
  • tomorrow(0)
  • payrate
  • shift
  • accruals keywords
  • overtime keywords (ot1threshold, ot2threshold, etc.)

Shift Script

Activating this script rule will add a Shift column to the time card. This is where you can designate a shift based on the client’s policy. This is the first box where you can designate the shift.
 

Useful Keywords Available

  • Employee Setup fields (any employee.xxxxx field)
  • Clock prompt field names
  • reportingdate object
  • category
  • hours
  • intime
  • outtime
  • touches
  • weekday
  • shift

Keywords Unavailable

  • yesterday(0)
  • tomorrow(0)
  • payrate
  • accruals keywords
  • overtime keywords (ot1threshold, ot2threshold, etc.)

Pay Rate Script

Here is where the pay rate can be adjusted. While the Employee Setup pay rates are available prior to this script box, you actually cannot set the pay rate on the time card until this script. This means if you are using a shift premium, you would have to set the premium here, even though the shift was designated in the prior script box.
  
Useful Keywords Available
  • Employee Setup fields (any employee.xxxxx field)
  • Clock prompt field names
  • payrate
  • category
  • reportingdate object
  • hours
  • intime
  • outtime
  • touches
  • weekday
  • shift

Keywords Unavailable

  • yesterday(0)
  • tomorrow(0)
  • accruals keywords
  • overtime keywords (ot1threshold, ot2threshold, etc.)

Accruals Script Boxes

The Accruals Scripts are actually composed of three different script boxes, the AccrueUp top box, the AccrueUp Bottom box and AccrueDown script.

AccrueUp Top Box

This box runs first of the three accrual boxes and runs on every line on the time card where there is punch / hours activity. This is where you would script an accrual that is based on hours worked. For instance, if an employee earns an hour of Sick for every 30 hours worked, you would accrue the hours in this box. This script will not run if there  is no activity on the day.
 

Useful Keywords Available

  • All keywords available in the Pay Rate script
  • Accruals keysords (accrueup, accruedown, getbalance, setbalance)

Keywords Not Available

  • yesterday(0)
  • tomorrow(0)
  • split
  • overtime keywords

‚Äč AccrueUp Bottom Box

This box is used to run once per day on the time card. It differs from all previous script boxes in that it will run even if there is no activity on the time card. This is different from the Top Box, which runs once per line, or punchset.
 
Another way to think of this is, if an employee has two punch sets on a day, the Bottom Accrue Up script will still run only once on that day. The top box would run twice if the employee had two punchsets on the day.
 
If the employee had no activity on the day, the top box would not run at all, the bottom box would run once.
 
  Useful Keywords Available
  • employee setup fields (and keyword starting with employee.)
  • reportingdate keywords
  • Accrual keywords

Keywords Not Available

  • hours
  • intime/outtime
  • clock prompt fields names
  • split
  • payrate
  • shift
  • category
  • overtime keywords
  • yesterday(0) / tomorrow(0)

AccrueDown Box

This script is used to see if the category of a time card entry matches an accrual category and, if it does, it can withdraw from the bucket. This script runs similarly to the top accrue up box in that it runs only if there is activity on the time card and it runs once on each row on the day.
 
So if an employee used 3 hours of Sick and 5 hours of Vacation on the same day, this script would run once through the Sick entry and lower the bucket by 3 hours, then run again on the Vacation entry, withdrawing 5 hours from that bucket.
 

Useful Keywords Available

  • Employee Setup fields
  • accrual keywords with the exception of accrueup
  • hours
  • category
  • reportingdate keywords

Keywords Not Available

  • accrueup
  • yesterday(0)/tomorrow(0)
  • overtime related keywords

OT Threshold Script

Unlike other script boxes, this script box is found in the Overtime category of the Processing Rules page, not the Script category. Its purpose is to apply both daily and weekly overtime rules that may not be accommodated by our predefined overtime rules. This script will run once per line on the time card and is aware of any daily and weekly thresholds which need to be tabulated.
 

Useful Keywords Available

  • Employee Setup fields
  • reportingdate keywords
  • clock prompt fields names
  • overtime threshold keywords(otday1threshold, otday2threshold, ot1threshold, etc.)
  Keywords Not Available
  • accruals keywords
  • split

Did you find this article helpful?