Skip to content
Snippets Groups Projects
Commit 05a82c6f authored by Sebastian Pongratz's avatar Sebastian Pongratz :ping_pong: Committed by Johannes Goderbauer
Browse files

[Projekt: Entwicklung - Neon][TicketNr.: 1054054][Leadimport-Rückgäng-Aktion]

parent e0bd5a65
No related branches found
No related tags found
No related merge requests found
...@@ -338,6 +338,13 @@ ...@@ -338,6 +338,13 @@
</entityParameter> </entityParameter>
</children> </children>
</entityConsumer> </entityConsumer>
<entityActionField>
<name>LeadimportReset</name>
<title>Leadimport Reset</title>
<onActionProcess>%aditoprj%/entity/Leadimport_entity/entityfields/leadimportreset/onActionProcess.js</onActionProcess>
<state>INVISIBLE</state>
<stateProcess>%aditoprj%/entity/Leadimport_entity/entityfields/leadimportreset/stateProcess.js</stateProcess>
</entityActionField>
</entityFields> </entityFields>
<recordContainers> <recordContainers>
<dbRecordContainer> <dbRecordContainer>
......
import("Date_lib");
import("system.logging");
import("system.vars");
import("KeywordRegistry_basic");
import("Sql_lib");
import("system.db");
let leadimportId = vars.get("$field.LEADIMPORTID");
var dateADayBefore = new Date();
dateADayBefore.setDate(dateADayBefore.getDate()-1);
// Delets all Data, which was created in the last 24 hours by the Leadimport
_deleteData("ORGANISATION", leadimportId, dateADayBefore);
_deleteData("PERSON", leadimportId, dateADayBefore);
_deleteData("ACTIVITY", leadimportId, dateADayBefore);
_deleteData("ACTIVITYLINK", leadimportId, dateADayBefore);
_deleteData("CONTACT", leadimportId, dateADayBefore);
_deleteData("ADDRESS", leadimportId, dateADayBefore);
_deleteData("COMMUNICATION", leadimportId, dateADayBefore);
_deleteData("AB_ATTRIBUTERELATION", leadimportId, dateADayBefore);
newWhere("LEADLOG.LEADIMPORT_ID", leadimportId)
.and("LEADLOG.DATE_NEW", dateADayBefore.getTime(), "# >= ?")
.from("LEADLOG")
.deleteData();
newWhere("LEAD.LEADIMPORT_ID", leadimportId)
.and("LEAD.DATE_NEW", dateADayBefore.getTime(), "# >= ?")
.from("LEAD")
.deleteData();
// Ändern des Status auf Created
newWhere("LEADIMPORT.LEADIMPORTID", leadimportId).updateData(true, "LEADIMPORT", ["Status"], null, [$KeywordRegistry.importStatus$created()]);
/**
* Deletes the Data with was created by the Leadimport of the given table
*
* @param {String} pTableName the tabele of deleteing Data of the Date of the Leadimport
* @param {String} pleadimportId the ID of the current Leadimport
* @param {Date} pdateADayBefor 24 hours befor now
*/
function _deleteData (pTableName, pleadimportId, pdateADayBefor)
{
newWhere(pTableName + "." + pTableName + "ID",
newSelect(pTableName + "." + pTableName + "ID")
.from(pTableName)
.join("LEADLOG", "LEADLOG.DATE_NEW = " + pTableName + ".DATE_NEW")
.where(pTableName + ".USER_NEW", "LEADLOG.USER_NEW")
.and("LEADLOG.LEADIMPORT_ID", pleadimportId)
.and("LEADLOG.DATE_NEW", pdateADayBefor.getTime(), "# >= ?"), SqlBuilder.IN())
.from(pTableName)
.deleteData();
}
\ No newline at end of file
import("system.logging");
import("system.result");
import("system.vars");
import("Sql_lib");
var dateADayBefore = new Date();
dateADayBefore.setDate(dateADayBefore.getDate()-1);
let count = newSelect("count(*)").from("LEADLOG").where("LEADLOG.LEADIMPORT_ID", vars.get("$field.LEADIMPORTID")).and("LEADLOG.DATE_NEW", dateADayBefore.getTime(), "# >= ?").arrayColumn();
if (count[0] > 0){
result.string("EDITABLE");
} else {
result.string("INVISIBLE");
}
\ No newline at end of file
...@@ -22,7 +22,7 @@ if (binMetadatas.length > 0) ...@@ -22,7 +22,7 @@ if (binMetadatas.length > 0)
var fieldSep = LeadImportUtils.getFieldSeparator(vars.get("$field.FIELDSEPARATOR")); var fieldSep = LeadImportUtils.getFieldSeparator(vars.get("$field.FIELDSEPARATOR"));
var fieldLimit = LeadImportUtils.getFieldLimit(vars.get("$field.FIELDDELIMITERS")); var fieldLimit = LeadImportUtils.getFieldLimit(vars.get("$field.FIELDDELIMITERS"));
var recordSep = LeadImportUtils.getRecordSeparator(vars.get("$field.SENTENCESEPARATOR")); var recordSep = LeadImportUtils.getRecordSeparator(vars.get("$field.SENTENCESEPARATOR"));
var currDate = vars.get("$sys.date");
var params = var params =
{ {
...@@ -34,7 +34,7 @@ if (binMetadatas.length > 0) ...@@ -34,7 +34,7 @@ if (binMetadatas.length > 0)
fieldLimit: fieldLimit, fieldLimit: fieldLimit,
user: user, user: user,
source: vars.getString("$field.IMPORTSOURCE"), source: vars.getString("$field.IMPORTSOURCE"),
currDate: vars.get("$sys.date"), currDate: currDate,
userId: EmployeeUtils.getCurrentUserId(), userId: EmployeeUtils.getCurrentUserId(),
importName: name importName: name
} }
......
...@@ -131,6 +131,7 @@ ...@@ -131,6 +131,7 @@
<name>jdito</name> <name>jdito</name>
<jDitoRecordAlias>Data_alias</jDitoRecordAlias> <jDitoRecordAlias>Data_alias</jDitoRecordAlias>
<isRequireContainerFiltering v="true" /> <isRequireContainerFiltering v="true" />
<isSortable v="true" />
<contentProcess>%aditoprj%/entity/Prod2prod_entity/recordcontainers/jdito/contentProcess.js</contentProcess> <contentProcess>%aditoprj%/entity/Prod2prod_entity/recordcontainers/jdito/contentProcess.js</contentProcess>
<hasDependentRecords v="true" /> <hasDependentRecords v="true" />
<onInsert>%aditoprj%/entity/Prod2prod_entity/recordcontainers/jdito/onInsert.js</onInsert> <onInsert>%aditoprj%/entity/Prod2prod_entity/recordcontainers/jdito/onInsert.js</onInsert>
......
...@@ -50,20 +50,21 @@ function ActivityUtils() {} ...@@ -50,20 +50,21 @@ function ActivityUtils() {}
* for example: * for example:
* <pre>[["number.txt", "MDExOCA5OTkgODgxIDk5OSAxMTkgNzI1IDM", true]]</pre> * <pre>[["number.txt", "MDExOCA5OTkgODgxIDk5OSAxMTkgNzI1IDM", true]]</pre>
* @param {String} [pDbAlias=current db alias] database alias where the activity shall be inserted * @param {String} [pDbAlias=current db alias] database alias where the activity shall be inserted
* @param {Date} [pDateNew] The Date which one is in the DB the DATE_NEW
* *
* @return {Object} js object where the following are filled: * @return {Object} js object where the following are filled:
* <ul> * <ul>
* <li>activityId</li> * <li>activityId</li>
* </ul> * </ul>
*/ */
ActivityUtils.insertNewActivity = function(pDataPreset, pActivityLinks, pDocuments, pDbAlias) ActivityUtils.insertNewActivity = function(pDataPreset, pActivityLinks, pDocuments, pDbAlias, pDateNew)
{ {
var dataPreset = pDataPreset || {}; var dataPreset = pDataPreset || {};
var dbAlias = pDbAlias || db.getCurrentAlias(); var dbAlias = pDbAlias || db.getCurrentAlias();
var insertStatements = []; var insertStatements = [];
var creationUser = dataPreset.userNew || vars.get("$sys.user"); var creationUser = dataPreset.userNew || vars.get("$sys.user");
var creationDate = datetime.date(); var creationDate = pDateNew || datetime.date();
var activityId = dataPreset.activityId || util.getNewUUID(); var activityId = dataPreset.activityId || util.getNewUUID();
var entrydate = dataPreset.entrydate || creationDate; var entrydate = dataPreset.entrydate || creationDate;
......
...@@ -198,9 +198,9 @@ LeadImportUtils.importData = function(pDataFields, pDataTypes, pFieldDef, pField ...@@ -198,9 +198,9 @@ LeadImportUtils.importData = function(pDataFields, pDataTypes, pFieldDef, pField
}; };
// History for organisation and person // History for organisation and person
if (orgContactId != "" && orgRet[3]) if (orgContactId != "" && orgRet[3])
ActivityUtils.insertNewActivity(activityData, new Array(new Array(orgObjID, orgContactId)));//org ActivityUtils.insertNewActivity(activityData, new Array(new Array(orgObjID, orgContactId)),undefined, undefined, pDate);//org
if (persContactId != "") if (persContactId != "")
ActivityUtils.insertNewActivity(activityData, new Array(new Array(persObjID, persContactId)));//pers ActivityUtils.insertNewActivity(activityData, new Array(new Array(persObjID, persContactId)), undefined, undefined, pDate);//pers
LeadValues["LEADIMPORT_ID"] = pImportDefID; LeadValues["LEADIMPORT_ID"] = pImportDefID;
LeadValues["ORGANISATION_ID"] = orgid; LeadValues["ORGANISATION_ID"] = orgid;
......
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