Skip to content
Snippets Groups Projects
Commit 58bf0706 authored by Sebastian Pongratz's avatar Sebastian Pongratz :ping_pong:
Browse files

#1058741-WriteEntityIntegration QuickEntry

parent a1989320
No related branches found
No related tags found
No related merge requests found
import("system.logging");
import("system.entities");
import("Sql_lib");
import("system.db");
import("system.vars");
import("KeywordRegistry_basic");
//TODO: use writeEntity when available
//TODO: duplicate check
var rowdata = vars.get("$local.rowdata");
var organisationId = rowdata["ORGANISATION_ID.value"];
var organisationId = "0";
var userNew = rowdata["USER_NEW.value"];
var dateNew = rowdata["DATE_NEW.value"];
var contactCols = [
"CONTACTID",
"ORGANISATION_ID",
"PERSON_ID",
"STATUS",
"ISOLANGUAGE",
"ADDRESS_ID",
"USER_NEW",
"DATE_NEW"
];
var contactVals = [
rowdata["UID.value"],
organisationId,
"",
$KeywordRegistry.contactStatus$active(),
rowdata["ISOLANGUAGE.value"],
"",
userNew,
dateNew
];
if (rowdata["ORGANISATION_NAME.value"])
{
var orgCols = [
"ORGANISATIONID",
"NAME",
"USER_NEW",
"DATE_NEW"
];
var orgVals = [
organisationId,
rowdata["ORGANISATION_NAME.value"],
userNew,
dateNew
];
db.insertData("ORGANISATION", orgCols, null, orgVals);
db.insertData("CONTACT", contactCols, null, contactVals);
}
else
{
contactVals[1] = "0"; //"private" if no company is given
let configOrg = entities.createConfigForAddingRows();
organisationId = rowdata["ORGANISATION_ID.value"];
configOrg.entity("Organisation_entity");
configOrg.fieldValues({
"ORGANISATIONID": organisationId,
"ORGANISATION_ID": organisationId,
"CONTACTID" : rowdata["UID.value"],
"NAME": rowdata["ORGANISATION_NAME.value"],
"USER_NEW": userNew,
"DATE_NEW": dateNew,
"USER_NEW_CONTACT": userNew,
"DATE_NEW_CONTACT" : dateNew,
"STATUS" : $KeywordRegistry.contactStatus$active(),
"ISOLANGUAGE" : "deu"
});
entities.createRow(configOrg);
}
if (rowdata["LASTNAME.value"])
{
var personCols = [
"PERSONID",
"FIRSTNAME",
"LASTNAME",
"SALUTATION",
"TITLE",
"GENDER",
"USER_NEW",
"DATE_NEW"
];
var gender = newSelect("SEX")
.from("SALUTATION")
.whereIfSet("SALUTATION.SALUTATION", rowdata["PERSON_SALUTATION.value"])
.cell(true);
var personVals = [
rowdata["PERSON_ID.value"],
rowdata["FIRSTNAME.value"] || "",
rowdata["LASTNAME.value"],
rowdata["PERSON_SALUTATION.value"] || "",
rowdata["PERSON_TITLE.value"] || "",
gender,
userNew,
dateNew
];
db.insertData("PERSON", personCols, null, personVals);
contactVals[0] = rowdata["PERSON_CONTACT_ID.value"];
contactVals[2] = rowdata["PERSON_ID.value"];
db.insertData("CONTACT", contactCols, null, contactVals);
let gender = newSelect("SEX")
.from("SALUTATION")
.whereIfSet("SALUTATION.SALUTATION", rowdata["PERSON_SALUTATION.value"])
.cell(true);
let configPer = entities.createConfigForAddingRows();
configPer.entity("Person_entity");
configPer.fieldValues({
"PERSON_ID" : rowdata["PERSON_ID.value"],
"PERSONID": rowdata["PERSON_ID.value"],
"FIRSTNAME": rowdata["FIRSTNAME.value"] || "",
"LASTNAME" : rowdata["LASTNAME.value"],
"SALUTATION": rowdata["PERSON_SALUTATION.value"] || "",
"TITLE": rowdata["PERSON_TITLE.value"] || "",
"GENDER": gender,
"USER_NEW": userNew,
"DATE_NEW": dateNew,
"USER_NEW_CONTACT": userNew,
"DATE_NEW_CONTACT" : dateNew,
"CONTACTID": rowdata["PERSON_CONTACT_ID.value"],
"ORGANISATION_ID": organisationId,
"STATUS" : $KeywordRegistry.contactStatus$active(),
"ISOLANGUAGE": rowdata["ISOLANGUAGE.value"]
});
entities.createRow(configPer);
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment