Skip to content
Snippets Groups Projects
Commit 5564a52a authored by Martin Groppe's avatar Martin Groppe
Browse files

Merge branch 'm_1080074_commSettingsLogHistory' into '2021.1.0'

1080074 communication settings in log history

See merge request xrm/basic!1024
parents e75f8f63 bfa1ef64
No related branches found
No related tags found
No related merge requests found
......@@ -18366,7 +18366,7 @@
<description></description>
<auditSyncConfig>
<name>auditSyncConfig</name>
<auditMode v="0" />
<auditMode v="1" />
<syncActive v="false" />
<syncComplete v="true" />
<syncDirection v="1" />
......@@ -18384,8 +18384,20 @@
<isUnique v="false" />
<index v="false" />
<documentation></documentation>
<title></title>
<title>Status</title>
<description></description>
<customProperties>
<customBooleanProperty>
<name>log</name>
<global v="false" />
<property v="true" />
</customBooleanProperty>
<customStringProperty>
<name>keyword</name>
<global v="false" />
<property>CommunicationSettingStatus</property>
</customStringProperty>
</customProperties>
</entityFieldDb>
<entityFieldDb>
<name>CHANNEL_ID</name>
......@@ -18398,8 +18410,20 @@
<isUnique v="false" />
<index v="true" />
<documentation></documentation>
<title></title>
<title>Channel</title>
<description></description>
<customProperties>
<customBooleanProperty>
<name>log</name>
<global v="false" />
<property v="true" />
</customBooleanProperty>
<customJDitoProperty>
<name>translate4Log</name>
<global v="false" />
<property>%aditoprj%/aliasDefinition/Data_alias/aliasdefinitionsub/entitygroup/entities/communicationsettings/entityfields/channel_id/customproperties/translate4log/property.js</property>
</customJDitoProperty>
</customProperties>
</entityFieldDb>
<entityFieldDb>
<name>CHANNEL_TYPE</name>
......@@ -18412,8 +18436,21 @@
<isUnique v="false" />
<index v="false" />
<documentation></documentation>
<title></title>
<title>Channel type</title>
<description></description>
<customProperties>
<customBooleanProperty>
<name>log</name>
<global v="false" />
<description></description>
<property v="true" />
</customBooleanProperty>
<customStringProperty>
<name>keyword</name>
<global v="false" />
<property>CommunicationChannelType</property>
</customStringProperty>
</customProperties>
</entityFieldDb>
<entityFieldDb>
<name>CONTACT_ID</name>
......@@ -18426,8 +18463,27 @@
<isUnique v="false" />
<index v="true" />
<documentation></documentation>
<title></title>
<title>Contact</title>
<description></description>
<customProperties>
<customBooleanProperty>
<name>log</name>
<global v="false" />
<property v="false" />
</customBooleanProperty>
<customStringProperty>
<name>tableRef</name>
<global v="false" />
<property>CONTACT</property>
</customStringProperty>
</customProperties>
<dependencies>
<entityDependency>
<name>776b88c0-8606-4445-b5f0-c7a258cd5b00</name>
<entityName>CONTACT</entityName>
<fieldName>CONTACTID</fieldName>
</entityDependency>
</dependencies>
</entityFieldDb>
<entityFieldDb>
<name>COMMUNICATIONSETTINGSID</name>
......@@ -18454,8 +18510,20 @@
<isUnique v="false" />
<index v="true" />
<documentation></documentation>
<title></title>
<title>Medium</title>
<description></description>
<customProperties>
<customBooleanProperty>
<name>log</name>
<global v="false" />
<property v="true" />
</customBooleanProperty>
<customStringProperty>
<name>keyword</name>
<global v="false" />
<property>CommunicationMediumCampaign</property>
</customStringProperty>
</customProperties>
</entityFieldDb>
<entityFieldDb>
<name>DATE_EDIT</name>
......
import("Sql_lib");
import("Contact_lib");
import("system.result");
import("Loghistory_lib");
import("PostalAddress_lib");
var params = Translate4LogParams.load();
var displayValue = "";
if (params.value)
{
displayValue = newSelect("ADDR")
.from("COMMUNICATION")
.where("COMMUNICATION.COMMUNICATIONID", params.value)
.cell();
if (!displayValue)
{
displayValue = AddressUtils.getFormattedOnlineAddressById(params.value);
}
}
result.string(displayValue);
\ No newline at end of file
......@@ -3,7 +3,7 @@ import("system.result");
import("Context_lib");
var res = [];
res.push({id: vars.get("$field.CONTACTID"), tableNames: ["CONTACT", "COMMUNICATION", "ADDRESS", "AB_ATTRIBUTERELATION"]});
res.push({id: vars.get("$field.CONTACTID"), tableNames: ["CONTACT", "COMMUNICATION", "ADDRESS", "AB_ATTRIBUTERELATION", "COMMUNICATIONSETTINGS"]});
res.push({id: vars.get("$field.ORGANISATIONID"), tableNames: ["ORGANISATION"]});
res = JSON.stringify(res);//currently only strings can be passed as param
......
......@@ -3,7 +3,7 @@ import("system.result");
import("Context_lib");
var res = [];
res.push({id: vars.get("$field.CONTACTID"), tableNames: ["CONTACT", "COMMUNICATION", "ADDRESS", "AB_ATTRIBUTERELATION", "DSGVODELETEFLAG", "DSGVO"]});
res.push({id: vars.get("$field.CONTACTID"), tableNames: ["CONTACT", "COMMUNICATION", "ADDRESS", "AB_ATTRIBUTERELATION", "DSGVODELETEFLAG", "DSGVO", "COMMUNICATIONSETTINGS"]});
res.push({id: vars.get("$field.PERSONID"), tableNames: ["PERSON"]});
res = JSON.stringify(res);//currently only strings can be passed as param
......
import("Context_lib");
import("system.vars");
import("system.util");
import("system.logging");
......@@ -19,6 +20,12 @@ import("Util_lib");
import("KeywordRegistry_basic");
import("system.entities");
const AuditSqlActions = {
INSERT: "I",
UPDATE: "U",
DELETE: "D"
};
/**
* object for writing the LogHistory based on audit-changes
* this object will be probably only usefull within the "process_audit"-process
......@@ -160,11 +167,11 @@ LogHistoryExecutor.prototype.generateLogHistory = function (pIdvalue, pExtra)
for(let i = 0; i < this.columns.length; i++ )
{
if (this.sqlAction == 'D' || this.sqlAction == 'U') oldvalues[this.columns[i]] = this.oldValues[i];
if (this.sqlAction == 'I' || this.sqlAction == 'U') newvalues[this.columns[i]] = this.newValues[i];
if (this.sqlAction == AuditSqlActions.DELETE || this.sqlAction == AuditSqlActions.UPDATE) oldvalues[this.columns[i]] = this.oldValues[i];
if (this.sqlAction == AuditSqlActions.INSERT || this.sqlAction == AuditSqlActions.UPDATE) newvalues[this.columns[i]] = this.newValues[i];
}
if (this.sqlAction == 'D') newvalues = oldvalues;
if ((this.sqlAction == 'D' || this.sqlAction == 'I') && newvalues[conf.IDs[1]])
if (this.sqlAction == AuditSqlActions.DELETE) newvalues = oldvalues;
if ((this.sqlAction == AuditSqlActions.DELETE || this.sqlAction == AuditSqlActions.INSERT) && newvalues[conf.IDs[1]])
{
pIdvalue = newvalues[conf.IDs[0]];
var data = this._getDataForExtras(newvalues[conf.IDs[1]], newvalues);
......@@ -173,7 +180,7 @@ LogHistoryExecutor.prototype.generateLogHistory = function (pIdvalue, pExtra)
else //this may happen for Attributes of type VOID (=attributes that have no values, compareable to "tags")
description.push(conf.Description + " " + data[0]);
}
if (this.sqlAction == 'U')
if (this.sqlAction == AuditSqlActions.UPDATE)
{
var ids = newSelect(conf.IDs).from(this.affectedTable).where([this.affectedTable, this.affectedTable + "ID"], pIdvalue).arrayRow();
pIdvalue = ids[0];
......@@ -213,20 +220,20 @@ LogHistoryExecutor.prototype.generateLogHistory = function (pIdvalue, pExtra)
if (references[this.columns[i]])
{
if (this.sqlAction == "I") references[this.columns[i]].id = this.newValues[i];
if (this.sqlAction == "D") references[this.columns[i]].id = this.oldValues[i];
if (this.sqlAction == AuditSqlActions.INSERT) references[this.columns[i]].id = this.newValues[i];
if (this.sqlAction == AuditSqlActions.DELETE) references[this.columns[i]].id = this.oldValues[i];
}
var logfield = columnStructure[this.columns[i]];
if (logfield && logfield.log)
{
if (this.sqlAction != 'I' && this.oldValues[i] != "")
if (this.sqlAction != AuditSqlActions.INSERT && this.oldValues[i] != "")
oldvalues[i] = this._getFormattedValue(this.columns[i], logfield, this.oldValues[i]);
if (this.sqlAction != 'D' && this.newValues[i] != "")
if (this.sqlAction != AuditSqlActions.DELETE && this.newValues[i] != "")
newvalues[i] = this._getFormattedValue(this.columns[i], logfield, this.newValues[i]);
var logfieldTitle = (logfield.title ? translate.text(logfield.title, this.translationLanguage) : translate.text("Value", this.translationLanguage));
if (this.sqlAction == 'U' && oldvalues[i] != newvalues[i])
if (this.sqlAction == AuditSqlActions.UPDATE && oldvalues[i] != newvalues[i])
{
//TODO: CLOB-check should be done by viewing the structure column type
//use .trim() for "[CLOB]" check because in some case the value "[CLOB]\n" my be given
......@@ -237,14 +244,14 @@ LogHistoryExecutor.prototype.generateLogHistory = function (pIdvalue, pExtra)
}
//use .trim() for "[CLOB]" check because in some case the value "[CLOB]\n" my be given
if (this.sqlAction == 'I' && newvalues[i] != "" && newvalues[i] != null && newvalues[i].trim() != "[CLOB]")
if (this.sqlAction == AuditSqlActions.INSERT && newvalues[i] != "" && newvalues[i] != null && newvalues[i].trim() != "[CLOB]")
description.push(logfieldTitle + ": \"" + newvalues[i] + "\"");
//use .trim() for "[CLOB]" check because in some case the value "[CLOB]\n" my be given
if (this.sqlAction == 'D' && oldvalues[i] != "" && oldvalues[i] != null && oldvalues[i].trim() != "[CLOB]")
if (this.sqlAction == AuditSqlActions.DELETE && oldvalues[i] != "" && oldvalues[i] != null && oldvalues[i].trim() != "[CLOB]")
description.push(logfieldTitle + ": \"" + oldvalues[i] + "\"");
}
}
if (this.sqlAction == "U")
if (this.sqlAction == AuditSqlActions.UPDATE)
{
for (let index in references) references[index].id = newSelect(index).from(this.affectedTable).where([this.affectedTable, primaryKey], this.idValue).cell();
}
......@@ -252,9 +259,9 @@ LogHistoryExecutor.prototype.generateLogHistory = function (pIdvalue, pExtra)
if (description.length > 0)
{
if (this.sqlAction == 'I') description = translate.withArguments("%0 added.", [description.join(",\n")], this.translationLanguage);
else if (this.sqlAction == 'U') description = translate.withArguments("%0 modified.", [description.join(",\n")], this.translationLanguage);
else if (this.sqlAction == 'D') description = translate.withArguments("%0 deleted.", [description.join(",\n")], this.translationLanguage);
if (this.sqlAction == AuditSqlActions.INSERT) description = translate.withArguments("%0 added.", [description.join(",\n")], this.translationLanguage);
else if (this.sqlAction == AuditSqlActions.UPDATE) description = translate.withArguments("%0 modified.", [description.join(",\n")], this.translationLanguage);
else if (this.sqlAction == AuditSqlActions.DELETE) description = translate.withArguments("%0 deleted.", [description.join(",\n")], this.translationLanguage);
}
return [description, pIdvalue, references];
}
......@@ -343,8 +350,8 @@ LogHistoryExecutor.prototype._getDataForExtras = function(pId, pValues)
*/
LogHistoryExecutor.prototype._getCalendarDescription = function (pIndex)
{
if (this.sqlAction != "D") this.newValues[pIndex] = _getEntry("DESCRIPTION:", this.newValues[pIndex]);
if (this.sqlAction != "I") this.oldValues[pIndex] = _getEntry("DESCRIPTION:", this.oldValues[pIndex]);
if (this.sqlAction != AuditSqlActions.DELETE) this.newValues[pIndex] = _getEntry("DESCRIPTION:", this.newValues[pIndex]);
if (this.sqlAction != AuditSqlActions.INSERT) this.oldValues[pIndex] = _getEntry("DESCRIPTION:", this.oldValues[pIndex]);
function _getEntry(pWert, pVcomponent)
{
......
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