Something went wrong on our end
-
David Büchler authoredDavid Büchler authored
conditionProcess.js 1.33 KiB
import("system.logging");
import("system.vars");
import("system.db");
import("system.result");
import("Sql_lib");
var cond = new SqlCondition();
cond.andPrepareVars("CONTACT.ORGANISATION_ID", "$param.OrgId_param")
.andPrepareVars("PERSON.CONTACT_ID", "$param.ContactId_param");
var onlyShowContactIds = JSON.parse(vars.get("$param.OnlyShowContactIds_param"));
var additionalCondition = SqlCondition.begin();
let alternativeCondition = "1 = 1";
if (vars.exists("$param.ExcludedContactIds_param") && vars.get("$param.ExcludedContactIds_param"))
{
var excludedContacts = JSON.parse(vars.getString("$param.ExcludedContactIds_param"));
excludedContacts.forEach(function(pContactId)
{
additionalCondition.andPrepare("CONTACT.CONTACTID", pContactId, "#<>?");
});
cond.andSqlCondition(additionalCondition, "1=1");
}
if(onlyShowContactIds != null && onlyShowContactIds.length > 0)
{
logging.log("hallo -> ");
onlyShowContactIds.forEach(function(pContactId)
{
logging.log("pContactId -> " + pContactId);
additionalCondition.orPrepare("CONTACT.CONTACTID", pContactId);
});
cond.andSqlCondition(additionalCondition, "1=2");
alternativeCondition = "1 = 2";
}
//TODO: use a preparedCondition when available #1030812 #1034026
result.string(db.translateCondition(cond.build(alternativeCondition)));