Skip to content
Snippets Groups Projects
Commit 367bdbea authored by Johannes Goderbauer's avatar Johannes Goderbauer
Browse files

add validation for new contact of duplicate entries

parent 92d27f5c
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,7 @@
<title>Contact</title>
<majorModelMode>DISTRIBUTED</majorModelMode>
<documentation>%aditoprj%/entity/Contact_entity/documentation.adoc</documentation>
<onValidation>%aditoprj%/entity/Contact_entity/onValidation.js</onValidation>
<iconId>VAADIN:USERS</iconId>
<recordContainer>db</recordContainer>
<entityFields>
......@@ -19,6 +20,7 @@
<consumer>Organisations</consumer>
<mandatory v="true" />
<displayValueProcess>%aditoprj%/entity/Contact_entity/entityfields/organisation_id/displayValueProcess.js</displayValueProcess>
<onValidation>%aditoprj%/entity/Contact_entity/entityfields/organisation_id/onValidation.js</onValidation>
<onValueChange>%aditoprj%/entity/Contact_entity/entityfields/organisation_id/onValueChange.js</onValueChange>
</entityField>
<entityField>
......
import("system.translate");
import("system.result");
import("system.db");
import("system.vars");
import("Entity_lib");
import("Sql_lib");
var personId = vars.get("$field.PERSON_ID");
var organisationId = ProcessHandlingUtils.getOnValidationValue("$field.ORGANISATION_ID");
if (personId && organisationId)
{
var alreadyExistantContactId = db.cell(SqlCondition.begin()
.andPrepare("CONTACT.PERSON_ID", personId)
.andPrepare("CONTACT.ORGANISATION_ID", organisationId)
.buildSql("select CONTACT.CONTACTID from CONTACT"));
if (alreadyExistantContactId != "")
result.string(translate.text("The combination of person and organisation does already exist and can not be created once more."));
}
\ 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