Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,93 @@
var shared = require("TriggerTestModule/EmployeeLib");
var console = require("console");

function managedColumns() {
return {
insert: ["Country"],
update: ["Country"],
};
}

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("exp.data: beforeInsert: row is: " + row);
if(row.Comments) {
if (row.Comments == "Individual Test") {
row.Country = "Inserting Single";
row.Comments = "BeforeDelete"; //set this for next test step
}
else if (row.Comments == "Import Test")
row.Country = "Importing TSV";
else if (row.Comments == "API Test")
row.Country = "API BeforeInsert";
var name = row.Name || row.name;
if (name === "Managed Insert") {
row.Country = "MANAGED-INS";
} else if (name === "Managed Struct") {
row.Country = "MANAGED-STRUCT";
row.undeclaredCol = "bad";
} else if (name === "Managed Struct Remove") {
row.Country = "MANAGED-STRUCT-REM";
delete row.Comments;
delete row.comments;
}

if (name === "Managed Unhandled") {
delete row.Country;
} else {
if (row.comments == "Individual Test") {
row.country = "Inserting Single";
row.comments = "BeforeDelete"; //set this for next test step
if (row.Comments) {
if (row.Comments === "Individual Test") {
row.Country = "Inserting Single";
row.Comments = "BeforeDelete"; //set this for next test step
} else if (row.Comments === "Import Test") {
row.Country = "Importing TSV";
} else if (row.Comments === "API Test") {
row.Country = "API BeforeInsert";
}
} else {
if (row.comments === "Individual Test") {
row.country = "Inserting Single";
row.comments = "BeforeDelete"; //set this for next test step
} else if (row.comments === "Import Test") {
row.country = "Importing TSV";
} else if (row.comments === "API Test") {
row.country = "API BeforeInsert";
}
}
else if (row.comments == "Import Test")
row.country = "Importing TSV";
else if (row.comments == "API Test")
row.country = "API BeforeInsert";
if (!row.Country)
row.Country = "DC-DEFAULT";
}

console.log("exp.data: edited row is: " + row);
console.log(shared.sampleFunc("exp.data: this is from the shared function"));
}

function beforeUpdate(row, oldRow, errors) {
console.log("exp.data: beforeUpdate: row is: " + row);
if(row.Comments == "BeforeUpdate")
row.Country = "Before Update changed me";
else if(row.comments == "BeforeUpdate")
row.country = "Before Update changed me";
var comments = row.Comments || row.comments;
if (comments === "Managed Update") {
row.Country = "MANAGED-UPD";
}
else if (comments === "Managed Struct") {
row.Country = "MANAGED-STRUCT";
row.undeclaredCol = "bad";
}
else if (comments === "Managed Struct Remove") {
row.Country = "MANAGED-STRUCT-REM";
delete row.Comments;
}

if (comments === "Managed Unhandled") {
delete row.Country;
} else {
if (row.Comments === "BeforeUpdate")
row.Country = "Before Update changed me";
else if (row.comments === "BeforeUpdate")
row.country = "Before Update changed me";
if (!row.Country)
row.Country = "DC-DEFAULT-UPD";
}
console.log("exp.data: old row is: " + oldRow);
console.log(shared.sampleFunc("exp.data: this is from the shared function"));
}

function beforeDelete(row, errors) {
console.log("exp.data: beforeDelete: row is: " + row);
if(row.Comments == "BeforeDelete" || row.comments == "BeforeDelete")
if (row.comments === "BeforeDelete")
errors[null] = "This is the Before Delete Error";

console.log(shared.sampleFunc("exp.data: this is from the shared function"));
Expand All @@ -58,7 +101,7 @@ function beforeDelete(row, errors) {
function afterInsert(row, errors) {
console.log("exp.data: afterInsert: row is: " + row);

if(row.Comments == "AfterInsert" || row.comments == "AfterInsert")
if (row.comments === "AfterInsert")
errors[null] = "This is the After Insert Error";

console.log(shared.sampleFunc("exp.data: this is from the shared function"));
Expand All @@ -67,7 +110,7 @@ function afterInsert(row, errors) {
function afterUpdate(row, oldRow, errors) {
console.log("exp.data: afterUpdate: row is: " + row);

if(row.Comments == "AfterUpdate" || row.comments == "AfterUpdate")
if (row.comments === "AfterUpdate")
errors[null] = "This is the After Update Error";

console.log("exp.data: old row is: " +oldRow);
Expand All @@ -77,7 +120,7 @@ function afterUpdate(row, oldRow, errors) {
function afterDelete(row, errors) {
console.log("exp.data: afterDelete: row is: " + row);

if(row.Country == "Before Update changed me" || row.country == "Before Update changed me")
if (row.country === "Before Update changed me")
errors[null] = "This is the After Delete Error";

console.log(shared.sampleFunc("exp.data: this is from the shared function"));
Expand Down
70 changes: 61 additions & 9 deletions modules/triggerTestModule/resources/queries/lists/Employees.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,87 @@
*/
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")
if (row.name === "Emp 2")
row.company = "Inserting Single";
else if(row.name == "Emp 5")
else if (row.name === "Emp 5")
row.company = "Importing TSV";
else if(row.name == "Emp 6")
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" )
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")
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"));
Expand All @@ -42,7 +94,7 @@ function beforeDelete(row, errors) {
function afterInsert(row, errors) {
console.log("list: afterInsert: row is: " + row);

if(row.name == "Emp 1")
if (row.name === "Emp 1")
errors[null] = "This is the After Insert Error";

console.log(shared.sampleFunc("list: this is from the shared function"));
Expand All @@ -51,7 +103,7 @@ function afterInsert(row, errors) {
function afterUpdate(row, oldRow, errors) {
console.log("list: afterUpdate: row is: " + row);

if(row.name == "Emp 2" || row.name == "Emp 6" )
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");

Expand All @@ -62,7 +114,7 @@ function afterUpdate(row, oldRow, errors) {
function afterDelete(row, errors) {
console.log("list: afterDelete: row is: " + row);

if(row.company == "Before Update changed me")
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"));
Expand Down
Loading
Loading