Weekly Timesheet Record Macros
The weekly timesheet record currently supports the checkTimeLimit and copyFromWeek macros.
For help working with this record in the UI, see Weekly Timesheets.
For information about SuiteScript 2.x record macros, see the following help topics:
checkTimeLimits
Corresponding UI Button |
Check Time Limits |
Macro Description |
Gathers the contents of the timeitem machine and sends to a service. Based on preferences, returns the results of a server check of time limits: either indicates that limits were not exceeded or provides a list of errors. |
Returns |
Limit check notifications |
Supported Script Types |
Client and server scripts For additional information, see SuiteScript 2.x Script Types. |
Since |
2018.2 |
Parameters
See Record.executeMacro(options) for details about parameters required for the execution of any macro. The checkTimeLimits macro also supports the following additional parameters.
Parameter |
Type |
Required / Optional |
Description |
Since |
---|---|---|---|---|
action |
string |
optional |
The action for which the limits are checked. May be one of the following:
Note:
Based on preferences enabled in the account, limits may not be checked for the approve action. If the submit action is available limits are not checked for the save action. |
2018.1 |
limitcheck |
boolean |
optional |
Checks limits regardless of the action. |
2018.1 |
Sample Return Objects
// Limit check with some errors but allow the user to continue, with optional preferences setting
{
notifications: [
{
title: "Maximum hours per day rule violated",
message: "4/17/2017 has more than 10:00 hours",
severity: {
label = "Warning",
value = 2
}
},
{
title: "Maximum hours per week rule violated",
message: "Week has more than 40:00 hours",
severity: {
label = "Warning",
value = 2
}
}
],
rules: [
{
name: "MAX_PER_DAY",
value: "8",
action: "WARN"
},
{
name: "MAX_PER_WEEK",
value: "48",
action: "DISALLOW"
}
]
}
//Limit check with no errors:
{
notifications: [
{
title: "Limit check successful",
message: "All time records meet their respective rules",
severity: {
label = "Information",
value = 1
}
}
]
}
Limit check that disallows continuation:
{
notifications: [
{
title: "Maximum hours per week rule violated",
message: "Week has more than 40:00 hours",
severity: {
label = "Error",
value = 3
}
}
]
}
copyFromWeek
Corresponding UI Button |
Copy From Week |
Macro Description |
Copies all lines from the specified week to the current weekly timesheet. Does not replace any lines in the weekly timesheet. Hours and memos may not be copied. |
Returns |
{notifications:[], response:{}} |
Supported Script Types |
Client and server scripts For additional information, see SuiteScript 2.x Script Types. |
Since |
2018.2 |
Parameters
See Record.executeMacro(options) for details about parameters required for the execution of any macro. The checkTimeLimits macro also requires the following additional parameters.
Parameter |
Type |
Required / Optional |
Description |
Since |
---|---|---|---|---|
weekOf |
date |
required |
The week from which to copy lines to the weekly timesheet. |
2018.1 |
copyExact |
boolean |
required |
Indicates whether hour and memo field values should be copied. |
2018.1 |
Weekly Timesheet Macros Syntax
require(['N/currentRecord', 'N/format'],function(currentRecord, format){
var timesheet = currentRecord.get();
// Copy time data from the week of 7/10, including hours and memos
timesheet.executeMacro({
id:'copyFromWeek',
params: {
weekOf : '7/10/2017',
copyExact : true
}
});
// Copy time data from the week of 14/10, but do not include hours and memos
timesheet.executeMacro({
id:'copyFromWeek',
params: {
weekOf : '14/10/2017',
copyExact : false
}
});
// Check whether the data currently in timesheet meet limits set by the administrator (for example, maximum of 40 hours per week, minimum of 6 hours per working day)
var limitCheckResult = timesheet.executeMacro({
id:'checkTimeLimits',
params: {
action : 'submit'
}
})
});