Skip to content
Snippets Groups Projects
Commit d7651d88 authored by Sebastian Listl's avatar Sebastian Listl :speech_balloon:
Browse files

1080075 communication setting channel type unique validation

parent 36662a88
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,7 @@
<title>Communication Settings</title>
<majorModelMode>DISTRIBUTED</majorModelMode>
<contentTitleProcess>%aditoprj%/entity/CommunicationSettings_entity/contentTitleProcess.js</contentTitleProcess>
<onValidation>%aditoprj%/entity/CommunicationSettings_entity/onValidation.js</onValidation>
<iconIdProcess>%aditoprj%/entity/CommunicationSettings_entity/iconIdProcess.js</iconIdProcess>
<titlePlural>Communication Settings</titlePlural>
<recordContainer>db</recordContainer>
......@@ -209,12 +210,17 @@
<name>VERSION</name>
<valueProcess>%aditoprj%/entity/CommunicationSettings_entity/entityfields/version/valueProcess.js</valueProcess>
</entityField>
<entityField>
<name>overrideInfo</name>
<valueProcess>%aditoprj%/entity/CommunicationSettings_entity/entityfields/overrideinfo/valueProcess.js</valueProcess>
</entityField>
</entityFields>
<recordContainers>
<dbRecordContainer>
<name>db</name>
<fromClauseProcess>%aditoprj%/entity/CommunicationSettings_entity/recordcontainers/db/fromClauseProcess.js</fromClauseProcess>
<conditionProcess>%aditoprj%/entity/CommunicationSettings_entity/recordcontainers/db/conditionProcess.js</conditionProcess>
<orderClauseProcess>%aditoprj%/entity/CommunicationSettings_entity/recordcontainers/db/orderClauseProcess.js</orderClauseProcess>
<alias>Data_alias</alias>
<recordFieldMappings>
<dbRecordFieldMapping>
......@@ -247,6 +253,7 @@
<dbRecordFieldMapping>
<name>CHANNEL_TYPE.displayValue</name>
<expression>%aditoprj%/entity/CommunicationSettings_entity/recordcontainers/db/recordfieldmappings/channel_type.displayvalue/expression.js</expression>
<columnAlias>channelTypeName</columnAlias>
</dbRecordFieldMapping>
<dbRecordFieldMapping>
<name>MEDIUM.displayValue</name>
......
import("Keyword_lib");
import("KeywordRegistry_basic");
import("system.translate");
import("system.result");
import("system.vars");
import("Sql_lib");
import("MarketingCondition_lib");
var channelType = vars.get("$field.CHANNEL_TYPE");
if (channelType == $KeywordRegistry.communicationChannelType$communication() || channelType == $KeywordRegistry.communicationChannelType$address())
{
var channelIdSql = "'" + vars.get("$field.CHANNEL_ID") + "'";
var superSettingCondition = new CommunicationSettingsCondition()
.contactId(vars.get("$field.CONTACT_ID"))
.rejected();
if (channelType == $KeywordRegistry.communicationChannelType$communication())
{
superSettingCondition.medium(vars.get("$field.MEDIUM"), channelIdSql);
}
else if (channelType == $KeywordRegistry.communicationChannelType$address())
{
superSettingCondition.address(channelIdSql);
}
var [superSettingId, superSettingChannelType, superSettingMedium, superSettingStatus] = superSettingCondition
.buildSelect(["COMMUNICATIONSETTINGSID", "CHANNEL_TYPE", "MEDIUM", "STATUS"])
.orderBy("CHANNEL_TYPE")
.arrayRow();
if (superSettingId && superSettingId != vars.get("$field.COMMUNICATIONSETTINGSID") && superSettingStatus != vars.get("$field.STATUS"))
{
var channelName = superSettingMedium
? KeywordUtils.getViewValue($KeywordRegistry.communicationMediumCampaign(), superSettingMedium)
: KeywordUtils.getViewValue($KeywordRegistry.communicationChannelType(), superSettingChannelType);
var settingTitle = channelName + " - " + KeywordUtils.getViewValue($KeywordRegistry.communicationSettingStatus(), superSettingStatus);
result.string(translate.withArguments("This setting is overridden by the setting '%0'", [settingTitle]));
}
}
\ No newline at end of file
import("system.translate");
import("system.result");
import("system.vars");
import("Sql_lib");
var channelType = vars.get("$field.CHANNEL_TYPE");
var medium = vars.get("$field.MEDIUM");
var channelId = vars.get("$field.CHANNEL_ID");
var alreadyExistsQuery = new SqlBuilder()
.selectCount()
.from("COMMUNICATIONSETTINGS")
.where("COMMUNICATIONSETTINGS.CONTACT_ID", vars.get("$field.CONTACT_ID"))
.and("COMMUNICATIONSETTINGS.COMMUNICATIONSETTINGSID", vars.get("$field.COMMUNICATIONSETTINGSID"), SqlBuilder.NOT_EQUAL())
.and("COMMUNICATIONSETTINGS.CHANNEL_TYPE", channelType);
if (medium)
{
alreadyExistsQuery.and("COMMUNICATIONSETTINGS.MEDIUM", medium);
}
else
{
alreadyExistsQuery.and("COMMUNICATIONSETTINGS.MEDIUM is null");
}
if (channelId)
{
alreadyExistsQuery.and("COMMUNICATIONSETTINGS.CHANNEL_ID", channelId);
}
else
{
alreadyExistsQuery.and("COMMUNICATIONSETTINGS.CHANNEL_ID is null");
}
if (alreadyExistsQuery.cell() > 0)
{
result.string(translate.text("A communication setting for this channel already exists!"));
}
\ No newline at end of file
import("system.db");
import("system.result");
result.object({
"channelTypeName": db.ASCENDING,
"MEDIUM": db.ASCENDING,
"CHANNEL_ID": db.ASCENDING
});
\ No newline at end of file
......@@ -8539,6 +8539,30 @@
<entry>
<key>Auto probability</key>
</entry>
<entry>
<key>Done by</key>
</entry>
<entry>
<key>Done on</key>
</entry>
<entry>
<key>First customer conversation</key>
</entry>
<entry>
<key>Further customer meetings</key>
</entry>
<entry>
<key>Post office box number</key>
</entry>
<entry>
<key>Project team</key>
</entry>
<entry>
<key>Prioritization based on segmentation parameters</key>
</entry>
<entry>
<key>Source / origin of the generation of contacts</key>
</entry>
</keyValueMap>
<font name="Dialog" style="0" size="11" />
<sqlModels>
......
......@@ -38,6 +38,10 @@
<key>%0 out of %1 records were changed to \"%2\".\n %3 record/s could not be updated.</key>
<value>%0 von %1 Datensätze wurden auf \"%2\" geändert.\n%3 Datensätze konnten nicht akutualisiert werden.</value>
</entry>
<entry>
<key>This setting is overridden by the setting '%0'</key>
<value>Diese Einstellung wird durch die Einstellung '%0' überschrieben</value>
</entry>
<entry>
<key>Value is too big, the maximum is %0</key>
<value>Wert ist zu groß, das Maximum ist %0</value>
......@@ -10269,6 +10273,10 @@ Bitte Datumseingabe prüfen</value>
<key>entity</key>
<value>Entität</value>
</entry>
<entry>
<key>A communication setting for this channel already exists!</key>
<value>Für diesen Kanal gibt es bereits eine Werbeeinstellung!</value>
</entry>
<entry>
<key>Zeigt wie viele Vertriebsprojekte in den einzelnen Vertriebsphasen sind. </key>
</entry>
......
......@@ -8624,6 +8624,30 @@
<entry>
<key>Auto probability</key>
</entry>
<entry>
<key>Done by</key>
</entry>
<entry>
<key>Done on</key>
</entry>
<entry>
<key>First customer conversation</key>
</entry>
<entry>
<key>Further customer meetings</key>
</entry>
<entry>
<key>Post office box number</key>
</entry>
<entry>
<key>Project team</key>
</entry>
<entry>
<key>Prioritization based on segmentation parameters</key>
</entry>
<entry>
<key>Source / origin of the generation of contacts</key>
</entry>
</keyValueMap>
<font name="Dialog" style="0" size="11" />
</language>
......@@ -15,6 +15,7 @@
<titleField>#CONTENTTITLE</titleField>
<subtitleField>STATUS</subtitleField>
<isEditable v="false" />
<informationField>overrideInfo</informationField>
</cardViewTemplate>
<genericViewTemplate>
<name>Infos</name>
......
......@@ -10,6 +10,7 @@ import("KeywordRegistry_basic");
function CommunicationSettingsCondition ()
{
this._contactIdSql = "CONTACT.CONTACTID";
this._contactId = null;
this._channelType = null;
this._medium = null;
this._channelIdSql = null;
......@@ -20,6 +21,14 @@ function CommunicationSettingsCondition ()
CommunicationSettingsCondition.prototype.contactIdField = function (pContactIdSql)
{
this._contactIdSql = pContactIdSql;
this._contactId = null;
return this;
}
CommunicationSettingsCondition.prototype.contactId = function (pContactId)
{
this._contactId = pContactId;
this._contactIdSql = null;
return this;
}
......@@ -120,8 +129,16 @@ CommunicationSettingsCondition.prototype.buildSelect = function (pSelectFields)
pSelectFields = "COMMUNICATIONSETTINGS.COMMUNICATIONSETTINGSID";
var sql = newSelect(pSelectFields)
.from("COMMUNICATIONSETTINGS")
.where("COMMUNICATIONSETTINGS.CONTACT_ID = " + this._contactIdSql)
.andIfSet("COMMUNICATIONSETTINGS.STATUS", this._settingStatus);
.whereIfSet("COMMUNICATIONSETTINGS.STATUS", this._settingStatus);
if (this._contactIdSql)
{
sql.and("COMMUNICATIONSETTINGS.CONTACT_ID = " + this._contactIdSql)
}
else if (this._contactId)
{
sql.and("COMMUNICATIONSETTINGS.CONTACT_ID", this._contactId);
}
var channelCondition = newWhere("COMMUNICATIONSETTINGS.CHANNEL_TYPE", $KeywordRegistry.communicationChannelType$global());
if (this._channelType)
......
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