Scripting Keywords - TWP

The following are keywords in the scripting engine of TimeWorksPlus. Most are able to be used in all scripting boxes, which can be accessed through Processing Rules, but there are some that will only work in certain script boxes. Please see Scripting Rule Boxes for more information on where a keyword can and can't be used.

Global - Available in all Scripting Rule Boxes

Employee (accessed by using "employee." followed by one of these labels that correspond to Employee Setup. For example employee.startdate
  • yearsofservice (a decimal number)
  • daysofservice (a decimal number)
  • monthsofservice (a decimal number)
  • anniversary (returns a whole number on the anniversary date of the employee)
  • monthiversary (returns a whole number on the anniversary date of the employee)
  • title
  • firstname
  • lastname
  • code
  • designation
  • startdate
  • enddate
  • department
  • location
  • supervisor
  • home1
  • home2
  • home3
  • autolunchhours
  • lunchminutes
  • accrualfactor
  • employeetype
  • accrualvalidator (employee field when BasicAccruals rule is activated)
Defined Operators - these relational operators can be used not only for mathematical functions, but also comparing other items in scripting.
  •     and • boolean operator
  •     or • boolean operator
  •     - • subtract operator
  •     + • addition operator
  •     * • multiply operator
  •     /, \ • divide operator, the / is a decimal division and the \ is an integer division
  •     %, mod • modulus operator, this returns the remainder of an integer division. 11.5 mod 5 = 1.5
  •     >, >= • greater than, greater than or equal to
  •     <, <= • less than, less than or equal to
  •     <> • does not equal 
  •     contains • checks to see if the string contains another string
  •     startswith • checks to see if the string starts with a particular string
  •     endswith • checks to see if the string ends with a particular string

Defined Variables are used to refer to certain values from the time card as well as checking certain conditions of punch sets.
  • hours = hours worked
  • minutes = minutes worked
  • seconds = seconds worked
  • breakseconds = break time in seconds
  • minutesout = amount of time elapsed between the current in punch to the previous out punch
  • minutesout(false) = same as above but include seconds as well.
  • minutestil = amount of time elapsed between the current out punch to the next in punch
  • punchset = the is times punch set number, so if an employee clocks in and out multiple times per day, this value will show in which sequence the punch set occurred.
  • category = the category of the punch
  • punchdate = date of the punch
  • intime = the time of the clock in punch
  • outtime = the time of the clock out punch
  • inismissing = false if the intime is not missing
  • outismissing = false if the outtime is not missing
  • istimes = true if there are times
  • ishours = true if only hours
  • ispayonly = true if dollars only
  • inisedited = true if intime was edited
  • outisedited = true if outtime was edited
  • hourstopunch = hours previous to the punch in question on that day
  • hourstopunchot = hours previous to the punch in question on that day that are overtime eligible
  • linetonow = the amount of seconds from the last punch to what it is right now (up to an 18 hour limit)
  • inip = the IP address of the in punch
  • outip = the IP address of the out punch

Defined Functions can be used to calculate and return values on a variable or value.
  • within     (ex. within( department , "100|110|200|210" ) = TRUE), returns true or false
  • translate  (ex. translate( department , "100|110|200|210", "Warehouse,Shipping,Accounting,Billing,Office" )), changes the selected item from one value to another
  • dateadd      (ex. dateadd("mm", 6, employee.startdate)), returns a date
  • dateserial      (ex. dateserial(reportingdate.year,12,31)), returns a date
  • weekday      (ex. weekday(punchdate)), returns the weekday of the date, MTWRFSU
  •  left      (ex. left("this is the best",4)) "this", returns the first amount of characters in a string of characters
  • right      (ex. right("this is the best",4)) "best", returns the last amount of characters in a string of characters
  • mid      (ex. mid("this is the best",6,2)) "is", returns the characters starting at the 6th, and takes two characters
  • val      (ex. val("5.555")) 5.555, returns a number instead of a string
  • cint      (ex. cint("5.555")) 5, returns an integer instead of a string or decimal number
  • cstr      (ex. cstr(5.555)) "5.555", returns a string instead of a number, date, time, or datetime
  • cdate      (ex. cdate("2014-11-25")) 2014-11-25, returns a date instead of a string
  • cdatetime      (ex. cdatetime("2014-11-25 08:00:00")) 2014-11-25 08:00:00, returns a datetime instead of a string
  • ctime      (ex. ctime(indt)) 17:00:00, returns a time instead of a datetime
  • round      (ex. round("7:45am-8:00am=8:00am")), rounds the time up or down
  • abs      (ex. abs(-5)) 5, returns a positive number
  • addalert      (ex. addalert("Late")), adds an alert to the time card
  • unpay      (ex. unpay(hours)), sets the amount defined in hours to unpaid.
  • touches      (ex. touches(6:00am,3:00pm)), returns true or false if punch set touches specified time
  • day - returns the day of the date object
  • month - returns the month of the date object
  • year  -returns the year of the date object
  • isedited - returns true if the string property given was edited for a particular punch

Overtime - available only in OTThreshold Script

  • ot1threshold = weekly overtime threshold
  • ot2threshold = weekly doubletime threshold
  • ot1daythreshold = daily overtime threshold
  • ot2daythreshold = daily doubletime threshold
  • otrules = one of the rules found in the overtime category of processing rules (for example: CA, NV, NO) ( ex. otrules("CA") )

Rounding - available only in RoundScript

  • round
  • roundin
  • roundout
  • roundends

Splits -

Can be used in Split or SplitPostReportingDate Script

  • split      (ex. split(12:00am)) - splits a punch at the specified time

ReportingDate

Can only be used in the ReportingDate Script

  • tomorrow     (ex. tomorrow(0)) pushes the punch to the next day
  • yesterday     (ex. yesterday(0)) pushes the punch to the previous day

AddEntryScript

addentry("type", amount, "category") - adds a new entry (hours or amount) on a time card
  (ex. addentry("hours", 8, "Regular"))
 

Keywords Available in SplitPostReporting, Shift, PayrateScript, Accruals and Overtime Script Rules

  • payrate
  • isfirsttoday
  • islasttoday
  • Reportingdate. Used with the following list of methods. Can also be used in the Accrual script boxes.
    • date
    • year
    • month
    • weekday
    • todaysdate = Returns the current date. Useful for determining if the time card day is in the past, present or future.
    • isfirstdayofmonth = Returns True on the first day of the month.
    • islastdayofmonth = Returns True on the last day of the month.
    • payperiodstart = Returns the date of the First day of the pay period.
    • payperiodend = Returns the date of the Last day of the pay period.
    • isholiday = Returns TRUE if the date is a holiday.
    • spread = returns the amount of time between the first in punch and the last out punch in a day, returns as a timespan. To get it as hours, use the following: val(reportingdate.spread) / 3600
    • totalhours = hours in the day
    • totalhoursot = hours in the day that are overtime eligible
    • hourstodate = hours to date in the week
    • hourstodateot = hourstodate in the week that are overtime eligible
    • weekhours = hours in the week
    • pphours = hours in the pay period
    • islastpunchpp = last punch date of the pay period
    • islastpunchweek = last punch date of the week
    • totalweek = returns the amounts in both numeric prompts and dollar amounts in the work week
    • totalpp = returns the amounts in both numeric prompts and dollar amounts in the pay period
    • totalday = returns the amounts in both numeric prompts and dollar amounts on the day of the punch
    • punchsets = returns how many punch sets are in the day
    • depthours = returns the amount of hours allocated to a particular labor prompt with a particular value in a day. (reportingdate.depthours("FieldNameOfLaborPrompt", "ValueOfLaborPrompt");)
    • schedhours = returns the amount of scheduled hours in the day. Can take an integer that specifies which sheduled line to get the hours from(reportingdate.schedhours(punchset);)
    • schedlines = returns the total amount of scheduled lines in the day (reportingdate.schedlines;)
    • schedin = returns the in time of the first scheduled line. Can take an integer that specifies which scheduled line to get the in time from (reportingdate.schedin(punchset);)
    • schedout = returns the out time of the first scheduled line. Can take an integer that specifies which scheduled line to get the out time from (reportingdate.schedout(punchset);)
    • schedplace = returns the place of the first scheduled line. Can take an integer that specifies which scheduled line to get the place from (reportingdate.schedplace(punchset);)
    • workweekend = Returns the date of the last day of the Work Week.

Accruals

Can only be used in the AccrueUp or AccrueDown script

  • accrueup     (ex. accrueup("PTO", 4, 160))
    • Accrues up the specified amount of hours in the chosen bucket
    • Has 5 arguments: Bucket Name, amount, maximum cap, vesting date, expiration date.
  • accruedown    (ex. accruedown("PTO", hours))
    • Accrues down the specified amount of hours in the chosen bucket
    • Has 3 arguments: Bucket Name, amount, minimum for bucket.
  • getbalance     (ex. getbalance("Hours"))
    • returns the number of hours in the bucket
  • setbalance     (ex. setbalance("Hours",0))
    • sets the balance of the bucket to the number you place after the comma

Attached to this article is a comprehensive document that you can print out as a reference.

Attachments

TimeWorksPlus_Scripting.docx TimeWorksPlus_Scripting.docx

Did you find this article helpful?