66var shared = require ( "TriggerTestModule/EmployeeLib" ) ;
77var console = require ( "console" ) ;
88
9+ function managedColumns ( ) {
10+ return {
11+ insert : [ "Country" ] ,
12+ update : [ "Country" ] ,
13+ } ;
14+ }
15+
916function init ( event , errors ) {
1017 console . log ( "init got triggered with event: " + event ) ;
1118 console . log ( shared . sampleFunc ( "this is from the shared function" ) ) ;
1219}
1320
1421function beforeInsert ( row , errors ) {
1522 console . log ( "exp.data: beforeInsert: row is: " + row ) ;
16- if ( row . Comments ) {
17- if ( row . Comments == "Individual Test" ) {
18- row . Country = "Inserting Single" ;
19- row . Comments = "BeforeDelete" ; //set this for next test step
20- }
21- else if ( row . Comments == "Import Test" )
22- row . Country = "Importing TSV" ;
23- else if ( row . Comments == "API Test" )
24- row . Country = "API BeforeInsert" ;
23+ var name = row . Name || row . name ;
24+ if ( name === "Managed Insert" ) {
25+ row . Country = "MANAGED-INS" ;
26+ } else if ( name === "Managed Struct" ) {
27+ row . Country = "MANAGED-STRUCT" ;
28+ row . undeclaredCol = "bad" ;
29+ } else if ( name === "Managed Struct Remove" ) {
30+ row . Country = "MANAGED-STRUCT-REM" ;
31+ delete row . Comments ;
32+ delete row . comments ;
33+ }
34+
35+ if ( name === "Managed Unhandled" ) {
36+ delete row . Country ;
2537 } else {
26- if ( row . comments == "Individual Test" ) {
27- row . country = "Inserting Single" ;
28- row . comments = "BeforeDelete" ; //set this for next test step
38+ if ( row . Comments ) {
39+ if ( row . Comments === "Individual Test" ) {
40+ row . Country = "Inserting Single" ;
41+ row . Comments = "BeforeDelete" ; //set this for next test step
42+ } else if ( row . Comments === "Import Test" ) {
43+ row . Country = "Importing TSV" ;
44+ } else if ( row . Comments === "API Test" ) {
45+ row . Country = "API BeforeInsert" ;
46+ }
47+ } else {
48+ if ( row . comments === "Individual Test" ) {
49+ row . country = "Inserting Single" ;
50+ row . comments = "BeforeDelete" ; //set this for next test step
51+ } else if ( row . comments === "Import Test" ) {
52+ row . country = "Importing TSV" ;
53+ } else if ( row . comments === "API Test" ) {
54+ row . country = "API BeforeInsert" ;
55+ }
2956 }
30- else if ( row . comments == "Import Test" )
31- row . country = "Importing TSV" ;
32- else if ( row . comments == "API Test" )
33- row . country = "API BeforeInsert" ;
57+ if ( ! row . Country )
58+ row . Country = "DC-DEFAULT" ;
3459 }
35-
3660 console . log ( "exp.data: edited row is: " + row ) ;
3761 console . log ( shared . sampleFunc ( "exp.data: this is from the shared function" ) ) ;
3862}
3963
4064function beforeUpdate ( row , oldRow , errors ) {
4165 console . log ( "exp.data: beforeUpdate: row is: " + row ) ;
42- if ( row . Comments == "BeforeUpdate" )
43- row . Country = "Before Update changed me" ;
44- else if ( row . comments == "BeforeUpdate" )
45- row . country = "Before Update changed me" ;
66+ var comments = row . Comments || row . comments ;
67+ if ( comments === "Managed Update" ) {
68+ row . Country = "MANAGED-UPD" ;
69+ }
70+ else if ( comments === "Managed Struct" ) {
71+ row . Country = "MANAGED-STRUCT" ;
72+ row . undeclaredCol = "bad" ;
73+ }
74+ else if ( comments === "Managed Struct Remove" ) {
75+ row . Country = "MANAGED-STRUCT-REM" ;
76+ delete row . Comments ;
77+ }
78+
79+ if ( comments === "Managed Unhandled" ) {
80+ delete row . Country ;
81+ } else {
82+ if ( row . Comments === "BeforeUpdate" )
83+ row . Country = "Before Update changed me" ;
84+ else if ( row . comments === "BeforeUpdate" )
85+ row . country = "Before Update changed me" ;
86+ if ( ! row . Country )
87+ row . Country = "DC-DEFAULT-UPD" ;
88+ }
4689 console . log ( "exp.data: old row is: " + oldRow ) ;
4790 console . log ( shared . sampleFunc ( "exp.data: this is from the shared function" ) ) ;
4891}
4992
5093function beforeDelete ( row , errors ) {
5194 console . log ( "exp.data: beforeDelete: row is: " + row ) ;
52- if ( row . Comments == "BeforeDelete" || row . comments == "BeforeDelete" )
95+ if ( row . comments = == "BeforeDelete" )
5396 errors [ null ] = "This is the Before Delete Error" ;
5497
5598 console . log ( shared . sampleFunc ( "exp.data: this is from the shared function" ) ) ;
@@ -58,7 +101,7 @@ function beforeDelete(row, errors) {
58101function afterInsert ( row , errors ) {
59102 console . log ( "exp.data: afterInsert: row is: " + row ) ;
60103
61- if ( row . Comments == "AfterInsert" || row . comments == "AfterInsert" )
104+ if ( row . comments = == "AfterInsert" )
62105 errors [ null ] = "This is the After Insert Error" ;
63106
64107 console . log ( shared . sampleFunc ( "exp.data: this is from the shared function" ) ) ;
@@ -67,7 +110,7 @@ function afterInsert(row, errors) {
67110function afterUpdate ( row , oldRow , errors ) {
68111 console . log ( "exp.data: afterUpdate: row is: " + row ) ;
69112
70- if ( row . Comments == "AfterUpdate" || row . comments == "AfterUpdate" )
113+ if ( row . comments = == "AfterUpdate" )
71114 errors [ null ] = "This is the After Update Error" ;
72115
73116 console . log ( "exp.data: old row is: " + oldRow ) ;
@@ -77,7 +120,7 @@ function afterUpdate(row, oldRow, errors) {
77120function afterDelete ( row , errors ) {
78121 console . log ( "exp.data: afterDelete: row is: " + row ) ;
79122
80- if ( row . Country == "Before Update changed me" || row . country == "Before Update changed me" )
123+ if ( row . country = == "Before Update changed me" )
81124 errors [ null ] = "This is the After Delete Error" ;
82125
83126 console . log ( shared . sampleFunc ( "exp.data: this is from the shared function" ) ) ;
0 commit comments