-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathEmployees.js
More file actions
126 lines (104 loc) · 3.81 KB
/
Employees.js
File metadata and controls
126 lines (104 loc) · 3.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/*
* Copyright (c) 2016-2018 LabKey Corporation
*
* Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
*/
var shared = require("TriggerTestModule/EmployeeLib");
var console = require("console");
function managedColumns() {
return {
insert: ["boomerang", "employeeId"],
update: ["boomerang", "company", "employeeId"],
ignored: ["notes"],
};
}
function init(event, errors) {
console.log("init got triggered with event: " + event);
console.log(shared.sampleFunc("this is from the shared function"));
}
function beforeInsert(row, errors) {
console.log("list: beforeInsert: row is: " + row);
if (row.name === "Emp 2")
row.company = "Inserting Single";
else if (row.name === "Emp 5")
row.company = "Importing TSV";
else if (row.name === "Emp 6")
row.company = "API BeforeInsert";
else if (row.name === "Managed Insert")
row.employeeId = "EMP-INS";
else if (row.name === "Managed Struct") {
row.employeeId = "EMP-STRUCT";
row.undeclaredCol = "bad";
}
else if (row.name === "Managed Struct Remove") {
row.employeeId = "EMP-STRUCT-REM";
delete row.SSN;
}
if (!row.employeeId) {
row.employeeId = "EMP-INS1";
}
row.notes = "This is a note";
if (row.SSN !== "-123") {
row.boomeRANG = "Back at ya!";
}
console.log("list: edited row is: " + row);
console.log(shared.sampleFunc("list: this is from the shared function"));
}
function beforeUpdate(row, oldRow, errors) {
console.log("list: beforeUpdate: row is: " + row);
if (row.name === "Emp 3" || row.name === "Emp 8")
row.company = "Before Update changed me";
else if (row.name === "Managed Update") {
row.company = "Managed Co";
row.employeeId = "EMP-UPD";
}
else if (row.name === "Managed Struct") {
row.company = "Struct Co";
row.employeeId = "EMP-STRUCT";
row.undeclaredCol = "bad";
}
else if (row.name === "Managed Struct Remove") {
row.company = "Struct Remove Co";
row.employeeId = "EMP-STRUCT-REM";
delete row.SSN;
}
if (!row.employeeId) {
row.employeeId = "EMP-UPD1";
}
row.notes = "This is a note";
if (row.SSN !== "-123") {
row.boomeRANG = "Back at me!";
}
console.log("list: old row is: " + oldRow);
console.log(shared.sampleFunc("list: this is from the shared function"));
}
function beforeDelete(row, errors) {
console.log("list: beforeDelete: row is: " + row);
if (row.company === "Inserting Single" || row.company === "DeleteMe")
errors[null] = "This is the Before Delete Error";
console.log(shared.sampleFunc("list: this is from the shared function"));
}
function afterInsert(row, errors) {
console.log("list: afterInsert: row is: " + row);
if (row.name === "Emp 1")
errors[null] = "This is the After Insert Error";
console.log(shared.sampleFunc("list: this is from the shared function"));
}
function afterUpdate(row, oldRow, errors) {
console.log("list: afterUpdate: row is: " + row);
if (row.name === "Emp 2" || row.name === "Emp 6" )
errors[null] = "This is the After Update Error";
//throw new Error("This is the After Update Error");
console.log("list: old row is: " +oldRow);
console.log(shared.sampleFunc("list: this is from the shared function"));
}
function afterDelete(row, errors) {
console.log("list: afterDelete: row is: " + row);
if (row.company === "Before Update changed me")
errors[null] = "This is the After Delete Error";
console.log(shared.sampleFunc("list: this is from the shared function"));
}
function complete(event, errors) {
console.log("list: complete got triggered with event: " + event);
console.log(shared.sampleFunc("list: this is from the shared function"));
}