Skip to content
Snippets Groups Projects
Commit 4be1c60d authored by S.Listl's avatar S.Listl
Browse files

1057635 Show Duplicates in OrganisationEdit_view

parent 8279cebb
No related branches found
No related tags found
No related merge requests found
......@@ -948,7 +948,6 @@
<entityProvider>
<name>SelfDuplicatesProvider</name>
<titlePlural>Duplicates</titlePlural>
<recordContainer>index</recordContainer>
</entityProvider>
<entityParameter>
<name>OnlyShowContactIds_param</name>
......@@ -1022,6 +1021,7 @@
</entityParameter>
<entityParameter>
<name>DuplicateCurrentContactId_param</name>
<title></title>
<valueProcess>%aditoprj%/entity/Organisation_entity/entityfields/selfduplicatesuncached/children/duplicatecurrentcontactid_param/valueProcess.js</valueProcess>
</entityParameter>
<entityParameter>
......
import("system.project");
import("system.indexsearch");
import("system.logging");
import("system.vars");
import("DuplicateScanner_lib");
import("system.result");
......
......@@ -5,65 +5,50 @@ import("system.vars");
import("DuplicateScanner_lib");
import("system.result");
let scannerName = "PersonDuplicates";
let targetEntity = "Person_entity";
let valuesToCheck = {};
var scannerName = "PersonDuplicates";
var targetEntity = "Person_entity";
var valuesToCheck = {};
var entityFieldsToLoad = DuplicateScannerUtils.GetEntityFieldsFromConfig(scannerName, targetEntity);
if(entityFieldsToLoad == null || entityFieldsToLoad.length == 0)
result.string(JSON.stringify(["nodata"]));
var idsForEmptyResult = JSON.stringify(["nodata"]);
if (entityFieldsToLoad == null || entityFieldsToLoad.length == 0)
result.string(idsForEmptyResult);
else
{
//Read the values of all available entity fields and write the fieldname7value combination
//as key/value pairs into an object. This is used to trigger the scan for duplicates
vars.get("$field.STANDARD_CITY");
vars.get("$field.STANDARD_ZIP");
vars.get("$field.STANDARD_ADDRESS");
vars.get("$field.FIRSTNAME");
vars.get("$field.LASTNAME");
vars.get("$field.PersAddresses.insertedRows")
vars.get("$field.PersAddresses.changedRows")
vars.get("$field.PersAddresses.deletedRows")
let field = '';
let fieldValue = '';
for (fieldname in entityFieldsToLoad)
{
field = entityFieldsToLoad[fieldname];
fieldValue = vars.get("$field." + field);
if(fieldValue != null && fieldValue != "")
{
valuesToCheck[field] = fieldValue;
}
}
let scanResults = DuplicateScannerUtils.ScanForDuplicates(scannerName, targetEntity,
valuesToCheck, null);
let duplicateIds = [];
if(scanResults != undefined && scanResults != null)
{
//Run thru every duplicate result and read out the id.
//Do it now to have a simple array on all usages lateron.
for (let i = 0; i < scanResults.length; i++)
{
let duplicateContactId = scanResults[i][indexsearch.FIELD_ID];
duplicateIds.push(duplicateContactId);
}
}
/*
* To achieve that if there are no duplicates, no contacts should be shown and therefore returned by the
* recordcontainer, an invalid id gets returned. It then is used in the conditionProcess to load the duplicates.
* Because of its invalidity, no records are shown.
*/
if(duplicateIds.length == 0)
result.string(JSON.stringify(["nodata"]));
else
result.string(JSON.stringify(duplicateIds));
}
vars.get("$field.STANDARD_CITY");
vars.get("$field.STANDARD_ZIP");
vars.get("$field.STANDARD_ADDRESS");
vars.get("$field.FIRSTNAME");
vars.get("$field.LASTNAME");
vars.get("$field.PersAddresses.insertedRows")
vars.get("$field.PersAddresses.changedRows")
vars.get("$field.PersAddresses.deletedRows")
for (let fieldname in entityFieldsToLoad)
{
var field = entityFieldsToLoad[fieldname];
var fieldValue = vars.get("$field." + field);
if (fieldValue)
valuesToCheck[field] = fieldValue;
}
var scanResults = DuplicateScannerUtils.ScanForDuplicates(scannerName, targetEntity, valuesToCheck, null) || [];
var duplicateIds = scanResults.map(function (duplicate)
{
return duplicate[indexsearch.FIELD_ID];
});
/*
* To achieve that if there are no duplicates, no contacts should be shown and therefore returned by the
* recordcontainer, an invalid id gets returned. It then is used in the conditionProcess to load the duplicates.
* Because of its invalidity, no records are shown.
*/
if (duplicateIds.length == 0)
result.string(idsForEmptyResult);
else
result.string(JSON.stringify(duplicateIds));
}
\ No newline at end of file
......@@ -11,6 +11,11 @@
</boxLayout>
</layout>
<children>
<neonViewReference>
<name>f2fa0351-15af-4d1c-b7dd-0e42d9c7889f</name>
<entityField>SelfDuplicatesUncached</entityField>
<view>OrganisationDuplicateEditview_view</view>
</neonViewReference>
<genericViewTemplate>
<name>Edit</name>
<editMode v="true" />
......
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