Skip to content
Snippets Groups Projects
Commit 9fee8914 authored by Martin Groppe's avatar Martin Groppe Committed by Benjamin Ulrich
Browse files

[Projekt: xRM-Marketing][TicketNr.: 1083293][Kampagnen, Stufenwechsel: autom....

[Projekt: xRM-Marketing][TicketNr.: 1083293][Kampagnen, Stufenwechsel: autom. erstellen von Aktivitäten]
parent a4578ade
No related branches found
No related tags found
No related merge requests found
Showing
with 200 additions and 4 deletions
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd">
<changeSet author="m.groppe" id="ceeac612-f3bb-4255-871a-854377fa425c">
<addColumn tableName="CAMPAIGNSTEP">
<column name="WORKFLOWDEFINITION_KEY" type="NVARCHAR(255)"/>
</addColumn>
</changeSet>
</databaseChangeLog>
\ No newline at end of file
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd">
<include relativeToChangelogFile="true" file="add_WorkflowDefinition_Key.xml"/>
</databaseChangeLog>
\ No newline at end of file
......@@ -2,6 +2,6 @@
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd">
<include relativeToChangelogFile="true" file="TopicTree/changelog.xml"/>
<include relativeToChangelogFile="true" file="CampaignStep/changelog.xml"/>
<include relativeToChangelogFile="true" file="xRM-Service/changelog.xml"/>
<include relativeToChangelogFile="true" file="xRM-Service/changelog.xml"/>
</databaseChangeLog>
</databaseChangeLog>
\ No newline at end of file
......@@ -9604,6 +9604,20 @@
<title></title>
<description></description>
</entityFieldDb>
<entityFieldDb>
<name>WORKFLOWDEFINITION_KEY</name>
<dbName></dbName>
<primaryKey v="false" />
<columnType v="12" />
<size v="255" />
<scale v="0" />
<notNull v="false" />
<isUnique v="false" />
<index v="false" />
<documentation></documentation>
<title></title>
<description></description>
</entityFieldDb>
</entityFields>
</entityDb>
<entityDb>
......
import("system.workflow");
import("ActivityTask_lib");
import("Contact_lib");
import("Employee_lib");
import("system.translate");
import("KeywordRegistry_basic");
import("system.logging");
import("Util_lib");
import("system.neon");
......@@ -40,22 +46,46 @@ function _handleRowIds(pParticipantRowIds, pCampaignId)
{
var oldStepIds = {};
var workflowDefinition_Key = newSelect("WORKFLOWDEFINITION_KEY")
.from("CAMPAIGNSTEP")
.where("CAMPAIGNSTEP.CAMPAIGNSTEPID",newCampaignStepId)
.cell();
if(isUpdate)
{
var stepNames = {}
newSelect(["CAMPAIGNSTEPID","NAME"])
.from("CAMPAIGNSTEP")
.where("CAMPAIGNSTEP.CAMPAIGN_ID",pCampaignId)
.table()
.forEach(function([campaignstepid, name])
{
stepNames[campaignstepid] = name;
});
var campaignName = CampaignUtils.getCampaignNameById(campaignId);
var employeeContactId = EmployeeUtils.getCurrentContactId() || "";
cols = [
"CAMPAIGNSTEP_ID",
"USER_EDIT",
"DATE_EDIT"
];
var contexts = {};
var oldSteps = newSelect("CONTACT_ID, CAMPAIGNSTEP_ID")
var oldSteps = newSelect("CONTACT_ID, CAMPAIGNSTEP_ID, PERSON_ID, ORGANISATION_ID")
.from("CAMPAIGNPARTICIPANT")
.join("CONTACT", "CAMPAIGNPARTICIPANT.CONTACT_ID = CONTACT.CONTACTID")
.whereIfSet("CAMPAIGNPARTICIPANT.CONTACT_ID", pParticipantRowIds, SqlBuilder.IN())
.and("CAMPAIGNPARTICIPANT.CAMPAIGN_ID", pCampaignId)
.table(true);
oldSteps.forEach(function(step)
{
contexts[step[0]] = ContactUtils.getContextByPersOrg(step[2], step[3]);
this[step[0]] = step[1];
}, oldStepIds);
}
......@@ -81,7 +111,27 @@ function _handleRowIds(pParticipantRowIds, pCampaignId)
if(isUpdate)
{
var oldCampaignStepId = oldStepIds[pParticipantRowIds[participant]] || "";
let activityData = {
categoryKeywordId : $KeywordRegistry.activityCategory$approval(),
directionKeywordId : $KeywordRegistry.activityDirection$internal(),
subject : translate.text("Campaignstep changed"),
content : translate.withArguments("Campaignstep in campaign \"%0\" changed from \"%1\" to \"%2\"", [campaignName, stepNames[oldCampaignStepId], stepNames[newCampaignStepId]]),
responsibleContactId: employeeContactId
};
let contactLink = [[contexts[pParticipantRowIds[participant]], pParticipantRowIds[participant]]];
ActivityUtils.insertNewActivity(activityData, contactLink);
if (workflowDefinition_Key)
{
let variables = {
"targetId":pParticipantRowIds[participant],
"tagetContext":contexts[pParticipantRowIds[participant]]};
workflow.startProcessByKey(workflowDefinition_Key, variables);
}
var updatedValues = [
newCampaignStepId,
......@@ -127,6 +177,15 @@ function _handleRowIds(pParticipantRowIds, pCampaignId)
vars.get("$sys.date"),
""
];
if (workflowDefinition_Key)
{
let variables = {
"targetId":pParticipantRowIds[participant],
"tagetContext": vars.get("$param.comingFrom_param")};
workflow.startProcessByKey(workflowDefinition_Key, variables);
}
statementArray.push(["CAMPAIGNPARTICIPANT", cols, null, valsCampaignParticipant]);
logArray.push(["CAMPAIGNPARTICIPANTLOG", colNamesCampaignParticipantLog, null, valsCampaignParticipantLog]);
......
......@@ -314,6 +314,7 @@
<fromClauseProcess>%aditoprj%/entity/CampaignParticipant_entity/recordcontainers/db/fromClauseProcess.js</fromClauseProcess>
<conditionProcess>%aditoprj%/entity/CampaignParticipant_entity/recordcontainers/db/conditionProcess.js</conditionProcess>
<onDBInsert>%aditoprj%/entity/CampaignParticipant_entity/recordcontainers/db/onDBInsert.js</onDBInsert>
<onDBUpdate>%aditoprj%/entity/CampaignParticipant_entity/recordcontainers/db/onDBUpdate.js</onDBUpdate>
<alias>Data_alias</alias>
<recordFieldMappings>
<dbRecordFieldMapping>
......
import("Contact_lib");
import("system.workflow");
import("Sql_lib");
import("system.vars");
import("Campaign_lib");
......@@ -7,5 +10,21 @@ var campaignStepId = rowdata["CAMPAIGNPARTICIPANT.CAMPAIGNSTEP_ID"];
var contactId = rowdata["CAMPAIGNPARTICIPANT.CONTACT_ID"];
var campaignParticipantId = vars.get("$local.uid");
var previousCampaignstepId = "";
var personId = rowdata["CONTACT.PERSON_ID"];
var organisationId = rowdata["CONTACT.ORGANISATION_ID"];
var workflowKey = newSelect("WORKFLOWDEFINITION_KEY")
.from("CAMPAIGNSTEP")
.where("CAMPAIGNSTEP.CAMPAIGNSTEPID",campaignStepId)
.cell();
if (workflowKey)
{
let variables = {
"targetId":contactId,
"tagetContext":ContactUtils.getContextByPersOrg(personId, organisationId)
};
workflow.startProcessByKey(workflowKey, variables);
}
CampaignUtils.createLogEntry(campaignId, campaignStepId, campaignParticipantId, previousCampaignstepId);
\ No newline at end of file
import("system.workflow");
import("Sql_lib");
import("Employee_lib");
import("system.translate");
import("KeywordRegistry_basic");
import("Contact_lib");
import("ActivityTask_lib");
import("system.vars");
import("Campaign_lib");
var initialrowdata = vars.get("$local.initialRowdata");
var rowdata = vars.get("$local.rowdata");
var campaignId = rowdata["CAMPAIGNPARTICIPANT.CAMPAIGN_ID"];
var campaignStepId = rowdata["CAMPAIGNPARTICIPANT.CAMPAIGNSTEP_ID"];
var contactId = rowdata["CAMPAIGNPARTICIPANT.CONTACT_ID"];
var campaignParticipantId = vars.get("$local.uid");
var previousCampaignStepId = initialrowdata["CAMPAIGNPARTICIPANT.CAMPAIGNSTEP_ID"];
var campaignName = CampaignUtils.getCampaignNameById(campaignId);
var campaignStepName = rowdata["#COLUMNEXP_____CAMPAIGNSTEP_ID.displayValue"];
var previousCampaignStepName = initialrowdata["#COLUMNEXP_____CAMPAIGNSTEP_ID.displayValue"];
var personId = rowdata["CONTACT.PERSON_ID"];
var organisationId = rowdata["CONTACT.ORGANISATION_ID"];
var currentContactId = EmployeeUtils.getCurrentContactId() || "";
var workflowKey = newSelect("WORKFLOWDEFINITION_KEY")
.from("CAMPAIGNSTEP")
.where("CAMPAIGNSTEP.CAMPAIGNSTEPID",campaignStepId)
.cell();
if (campaignStepId != previousCampaignStepId)
{
let activityData = {
categoryKeywordId : $KeywordRegistry.activityCategory$approval(),
directionKeywordId : $KeywordRegistry.activityDirection$internal(),
subject : translate.text("Campaignstep changed"),
content : translate.withArguments("Campaignstep in campaign \"%0\" changed from \"%1\" to \"%2\"", [campaignName, previousCampaignStepName, campaignStepName]),
responsibleContactId: currentContactId
};
var context = ContactUtils.getContextByPersOrg(personId, organisationId)
let contactLink = [[context, contactId]];
ActivityUtils.insertNewActivity(activityData, contactLink);
CampaignUtils.createLogEntry(campaignId, campaignStepId, campaignParticipantId, previousCampaignStepId);
if (workflowKey)
{
let variables = {
"targetId":contactId,
"tagetContext":context
};
workflow.startProcessByKey(workflowKey, variables);
}
}
......@@ -413,6 +413,19 @@
</entityActionField>
</children>
</entityActionGroup>
<entityField>
<name>WORKFLOWDEFINITION_KEY</name>
<title>Workflow</title>
<consumer>Workflows</consumer>
</entityField>
<entityConsumer>
<name>Workflows</name>
<dependency>
<name>dependency</name>
<entityName>WorkflowDefinition_entity</entityName>
<fieldName>#PROVIDER</fieldName>
</dependency>
</entityConsumer>
</entityFields>
<recordContainers>
<dbRecordContainer>
......@@ -515,6 +528,10 @@
<name>EMPLOYEE_CONTACT_ID.displayValue</name>
<expression>%aditoprj%/entity/CampaignStep_entity/recordcontainers/db/recordfieldmappings/employee_contact_id.displayvalue/expression.js</expression>
</dbRecordFieldMapping>
<dbRecordFieldMapping>
<name>WORKFLOWDEFINITION_KEY.value</name>
<recordfield>CAMPAIGNSTEP.WORKFLOWDEFINITION_KEY</recordfield>
</dbRecordFieldMapping>
</recordFieldMappings>
<linkInformation>
<linkInformation>
......
......@@ -57,6 +57,10 @@
<name>eff370e3-6805-46ad-ab7f-03d8a6392420</name>
<entityField>STEPMEDIUM</entityField>
</entityFieldLink>
<entityFieldLink>
<name>71db7feb-51ca-46dc-b041-87655520bb08</name>
<entityField>WORKFLOWDEFINITION_KEY</entityField>
</entityFieldLink>
</fields>
</genericViewTemplate>
</children>
......
......@@ -58,6 +58,10 @@
<name>aa317ce2-058b-4956-9bbc-ce5477436e2d</name>
<entityField>STEPMEDIUM</entityField>
</neonTableColumn>
<neonTableColumn>
<name>331da0c2-3f66-4acd-aaa1-9b5b9d1b3f42</name>
<entityField>WORKFLOWDEFINITION_KEY</entityField>
</neonTableColumn>
</columns>
</tableViewTemplate>
<treeTableViewTemplate>
......@@ -101,6 +105,10 @@
<name>f4ab8967-0161-4aeb-a1ec-d21f88e77385</name>
<entityField>STEPMEDIUM</entityField>
</neonTreeTableColumn>
<neonTreeTableColumn>
<name>45494c24-ae12-4beb-a991-002b7046eff1</name>
<entityField>WORKFLOWDEFINITION_KEY</entityField>
</neonTreeTableColumn>
</columns>
</treeTableViewTemplate>
</children>
......
......@@ -58,6 +58,10 @@
<name>32c55d58-72c7-4af0-9236-a019149656d4</name>
<entityField>CampaignStatus</entityField>
</entityFieldLink>
<entityFieldLink>
<name>770b6bcb-8965-413b-a5c8-c917c228f836</name>
<entityField>WORKFLOWDEFINITION_KEY</entityField>
</entityFieldLink>
</fields>
</genericViewTemplate>
<scoreCardViewTemplate>
......
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