Something went wrong on our end
process.js 1.07 KiB
import("system.db");
import("KeywordRegistry_basic");
import("Keyword_lib");
import("Sql_lib");
var salesprojectPhaseDefs = newSelect("CHECKLIST_ID, PHASE, DESCRIPTION, AUTOPROBABILITY").from("SALESPROJECTPHASEDEFINITION").table();
var updates = [];
var table = "CHECKLIST";
var cols = ["TITLE", "DESCRIPTION", "COND", "CONTEXT", "AUTOPROBABILITY"];
salesprojectPhaseDefs.forEach(function([checklistId, phase, description, autoprobability]){
let filterCond = "{\"entity\":\"Salesproject_entity\",\"filter\":{\"type\":\"group\",\"operator\":\"AND\",\"childs\":[{\"type\":\"row\",\"name\":\"PHASE\",\"operator\":\"EQUAL\",\"value\":\"" + KeywordUtils.getViewValue($KeywordRegistry.salesprojectPhase(), phase) + "\",\"key\":\"" + phase + "\",\"contenttype\":\"TEXT\"}]}}";
description = description || translate.text("Checklist"); //avoid null values
let vals = [description, description, filterCond, "Salesproject", autoprobability];
let cond = newWhere("CHECKLIST.CHECKLISTID", checklistId).toString();
updates.push([table, cols, null, vals, cond]);
});
db.updates(updates);