From 7a52f1663eef95299d9e5fb77cef32e9035f15c3 Mon Sep 17 00:00:00 2001
From: "S.Listl" <S.Listl@SLISTL.aditosoftware.local>
Date: Wed, 31 Jul 2019 12:03:55 +0200
Subject: [PATCH] Bulkmail bugfixing, chart

---
 entity/Activity_entity/Activity_entity.aod    |  5 ++
 .../entityfields/direction/valueProcess.js    |  6 ++
 .../recordcontainers/jdito/contentProcess.js  | 16 +++++
 .../BulkMailStatusChart_entity.aod            | 60 +++++++++++++++++++
 .../recordcontainers/jdito/contentProcess.js  | 16 +++++
 entity/BulkMail_entity/BulkMail_entity.aod    | 21 +++++++
 .../createactivities/dropDownProcess.js       |  7 +++
 .../createactivities/valueProcess.js          |  6 ++
 .../children/bulkmailid_param/valueProcess.js |  4 ++
 .../LetterRecipient_entity.aod                | 12 ++++
 .../recordcontainers/db/fromClauseProcess.js  |  3 +-
 .../address_id.displayvalue/expression.js     |  5 ++
 .../recordcontainers/jdito/onInsert.js        |  3 +-
 .../_____LANGUAGE_EXTRA.aod                   |  6 ++
 .../_____LANGUAGE_de/_____LANGUAGE_de.aod     |  4 ++
 .../_____LANGUAGE_en/_____LANGUAGE_en.aod     |  6 ++
 .../BulkMailStatusChart.aod                   | 12 ++++
 .../BulkMailEdit_view/BulkMailEdit_view.aod   |  4 ++
 .../BulkMailPreview_view.aod                  | 10 ++++
 .../BulkMailStatusChart_view.aod              | 20 +++++++
 .../LetterRecipientFilter_view.aod            |  4 ++
 process/ActivityTask_lib/process.js           | 10 +++-
 22 files changed, 235 insertions(+), 5 deletions(-)
 create mode 100644 entity/Activity_entity/entityfields/direction/valueProcess.js
 create mode 100644 entity/BulkMailChart_entity/recordcontainers/jdito/contentProcess.js
 create mode 100644 entity/BulkMailStatusChart_entity/BulkMailStatusChart_entity.aod
 create mode 100644 entity/BulkMailStatusChart_entity/recordcontainers/jdito/contentProcess.js
 create mode 100644 entity/BulkMail_entity/entityfields/createactivities/dropDownProcess.js
 create mode 100644 entity/BulkMail_entity/entityfields/createactivities/valueProcess.js
 create mode 100644 entity/BulkMail_entity/entityfields/recipientstatuschart/children/bulkmailid_param/valueProcess.js
 create mode 100644 entity/LetterRecipient_entity/recordcontainers/db/recordfieldmappings/address_id.displayvalue/expression.js
 create mode 100644 neonContext/BulkMailStatusChart/BulkMailStatusChart.aod
 create mode 100644 neonView/BulkMailStatusChart_view/BulkMailStatusChart_view.aod

diff --git a/entity/Activity_entity/Activity_entity.aod b/entity/Activity_entity/Activity_entity.aod
index cee39ed0d3..5f23c46537 100644
--- a/entity/Activity_entity/Activity_entity.aod
+++ b/entity/Activity_entity/Activity_entity.aod
@@ -18,6 +18,7 @@
       <consumer>KeywordDirections</consumer>
       <groupable v="true" />
       <mandatory v="true" />
+      <valueProcess>%aditoprj%/entity/Activity_entity/entityfields/direction/valueProcess.js</valueProcess>
       <displayValueProcess>%aditoprj%/entity/Activity_entity/entityfields/direction/displayValueProcess.js</displayValueProcess>
     </entityField>
     <entityField>
@@ -467,6 +468,10 @@
       <name>PresetDocuments_param</name>
       <expose v="true" />
     </entityParameter>
+    <entityParameter>
+      <name>Direction_param</name>
+      <expose v="true" />
+    </entityParameter>
   </entityFields>
   <recordContainers>
     <dbRecordContainer>
diff --git a/entity/Activity_entity/entityfields/direction/valueProcess.js b/entity/Activity_entity/entityfields/direction/valueProcess.js
new file mode 100644
index 0000000000..e219a5baf3
--- /dev/null
+++ b/entity/Activity_entity/entityfields/direction/valueProcess.js
@@ -0,0 +1,6 @@
+import("system.neon");
+import("system.vars");
+import("system.result");
+
+if (vars.get("$this.value") == null && vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.exists("$param.Direction_param"))
+    result.string(vars.get("$param.Direction_param"));
\ No newline at end of file
diff --git a/entity/BulkMailChart_entity/recordcontainers/jdito/contentProcess.js b/entity/BulkMailChart_entity/recordcontainers/jdito/contentProcess.js
new file mode 100644
index 0000000000..0869420384
--- /dev/null
+++ b/entity/BulkMailChart_entity/recordcontainers/jdito/contentProcess.js
@@ -0,0 +1,16 @@
+import("system.db");
+import("system.result");
+import("Sql_lib");
+import("Keyword_lib");
+import("KeywordRegistry_basic");
+import("system.vars");
+
+var bulkMailId = vars.get("$param.BulkMailId_param");
+
+var query = SqlBuilder.begin()
+    .select(["STATUS", "STATUS", KeywordUtils.getResolvedTitleSqlPart($KeywordRegistry.bulkMailRecipientStatus(), "STATUS"), "count(STATUS)"])
+    .from("BULKMAILRECIPIENT")
+    .where(SqlCondition.begin().andPrepare("BULKMAILRECIPIENT.BULKMAIL_ID", bulkMailId))
+    .groupBy("STATUS");
+
+result.object(db.table(query.build()));
\ No newline at end of file
diff --git a/entity/BulkMailStatusChart_entity/BulkMailStatusChart_entity.aod b/entity/BulkMailStatusChart_entity/BulkMailStatusChart_entity.aod
new file mode 100644
index 0000000000..0c0b218c5f
--- /dev/null
+++ b/entity/BulkMailStatusChart_entity/BulkMailStatusChart_entity.aod
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.3.10" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.3.10">
+  <name>BulkMailStatusChart_entity</name>
+  <majorModelMode>DISTRIBUTED</majorModelMode>
+  <title>Recipient status</title>
+  <titlePlural>Recipient status</titlePlural>
+  <recordContainer>jdito</recordContainer>
+  <entityFields>
+    <entityProvider>
+      <name>#PROVIDER</name>
+    </entityProvider>
+    <entityField>
+      <name>X</name>
+      <title>Recipients</title>
+    </entityField>
+    <entityField>
+      <name>Y</name>
+    </entityField>
+    <entityParameter>
+      <name>BulkMailId_param</name>
+      <expose v="true" />
+      <mandatory v="true" />
+    </entityParameter>
+    <entityField>
+      <name>UID</name>
+    </entityField>
+    <entityProvider>
+      <name>RecipientStatusChart</name>
+      <dependencies>
+        <entityDependency>
+          <name>e2d96467-ec53-424b-b78c-c97c2db2bb8a</name>
+          <entityName>BulkMail_entity</entityName>
+          <fieldName>RecipientStatusChart</fieldName>
+          <isConsumer v="false" />
+        </entityDependency>
+      </dependencies>
+    </entityProvider>
+  </entityFields>
+  <recordContainers>
+    <jDitoRecordContainer>
+      <name>jdito</name>
+      <jDitoRecordAlias>Data_alias</jDitoRecordAlias>
+      <contentProcess>%aditoprj%/entity/BulkMailStatusChart_entity/recordcontainers/jdito/contentProcess.js</contentProcess>
+      <recordFieldMappings>
+        <jDitoRecordFieldMapping>
+          <name>UID.value</name>
+        </jDitoRecordFieldMapping>
+        <jDitoRecordFieldMapping>
+          <name>X.value</name>
+        </jDitoRecordFieldMapping>
+        <jDitoRecordFieldMapping>
+          <name>X.displayValue</name>
+        </jDitoRecordFieldMapping>
+        <jDitoRecordFieldMapping>
+          <name>Y.value</name>
+        </jDitoRecordFieldMapping>
+      </recordFieldMappings>
+    </jDitoRecordContainer>
+  </recordContainers>
+</entity>
diff --git a/entity/BulkMailStatusChart_entity/recordcontainers/jdito/contentProcess.js b/entity/BulkMailStatusChart_entity/recordcontainers/jdito/contentProcess.js
new file mode 100644
index 0000000000..0869420384
--- /dev/null
+++ b/entity/BulkMailStatusChart_entity/recordcontainers/jdito/contentProcess.js
@@ -0,0 +1,16 @@
+import("system.db");
+import("system.result");
+import("Sql_lib");
+import("Keyword_lib");
+import("KeywordRegistry_basic");
+import("system.vars");
+
+var bulkMailId = vars.get("$param.BulkMailId_param");
+
+var query = SqlBuilder.begin()
+    .select(["STATUS", "STATUS", KeywordUtils.getResolvedTitleSqlPart($KeywordRegistry.bulkMailRecipientStatus(), "STATUS"), "count(STATUS)"])
+    .from("BULKMAILRECIPIENT")
+    .where(SqlCondition.begin().andPrepare("BULKMAILRECIPIENT.BULKMAIL_ID", bulkMailId))
+    .groupBy("STATUS");
+
+result.object(db.table(query.build()));
\ No newline at end of file
diff --git a/entity/BulkMail_entity/BulkMail_entity.aod b/entity/BulkMail_entity/BulkMail_entity.aod
index eb2d7d4974..5d149ff585 100644
--- a/entity/BulkMail_entity/BulkMail_entity.aod
+++ b/entity/BulkMail_entity/BulkMail_entity.aod
@@ -159,6 +159,27 @@
         </entityParameter>
       </children>
     </entityConsumer>
+    <entityField>
+      <name>CREATEACTIVITIES</name>
+      <title>Create activities</title>
+      <contentType>BOOLEAN</contentType>
+      <dropDownProcess>%aditoprj%/entity/BulkMail_entity/entityfields/createactivities/dropDownProcess.js</dropDownProcess>
+      <valueProcess>%aditoprj%/entity/BulkMail_entity/entityfields/createactivities/valueProcess.js</valueProcess>
+    </entityField>
+    <entityConsumer>
+      <name>RecipientStatusChart</name>
+      <dependency>
+        <name>dependency</name>
+        <entityName>BulkMailStatusChart_entity</entityName>
+        <fieldName>RecipientStatusChart</fieldName>
+      </dependency>
+      <children>
+        <entityParameter>
+          <name>BulkMailId_param</name>
+          <valueProcess>%aditoprj%/entity/BulkMail_entity/entityfields/recipientstatuschart/children/bulkmailid_param/valueProcess.js</valueProcess>
+        </entityParameter>
+      </children>
+    </entityConsumer>
   </entityFields>
   <recordContainers>
     <dbRecordContainer>
diff --git a/entity/BulkMail_entity/entityfields/createactivities/dropDownProcess.js b/entity/BulkMail_entity/entityfields/createactivities/dropDownProcess.js
new file mode 100644
index 0000000000..3373b8a886
--- /dev/null
+++ b/entity/BulkMail_entity/entityfields/createactivities/dropDownProcess.js
@@ -0,0 +1,7 @@
+import("system.translate");
+import("system.result");
+
+result.object([
+    ["1", translate.text("Yes")],
+    ["0", translate.text("No")]
+]);
\ No newline at end of file
diff --git a/entity/BulkMail_entity/entityfields/createactivities/valueProcess.js b/entity/BulkMail_entity/entityfields/createactivities/valueProcess.js
new file mode 100644
index 0000000000..72e22f0a52
--- /dev/null
+++ b/entity/BulkMail_entity/entityfields/createactivities/valueProcess.js
@@ -0,0 +1,6 @@
+import("system.neon");
+import("system.vars");
+import("system.result");
+
+if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.get("$this.value") == null)
+    result.string("1");
\ No newline at end of file
diff --git a/entity/BulkMail_entity/entityfields/recipientstatuschart/children/bulkmailid_param/valueProcess.js b/entity/BulkMail_entity/entityfields/recipientstatuschart/children/bulkmailid_param/valueProcess.js
new file mode 100644
index 0000000000..2a12b8389b
--- /dev/null
+++ b/entity/BulkMail_entity/entityfields/recipientstatuschart/children/bulkmailid_param/valueProcess.js
@@ -0,0 +1,4 @@
+import("system.vars");
+import("system.result");
+
+result.string(vars.get("$field.BULKMAILID"));
\ No newline at end of file
diff --git a/entity/LetterRecipient_entity/LetterRecipient_entity.aod b/entity/LetterRecipient_entity/LetterRecipient_entity.aod
index 492db4ac95..eb34d0f564 100644
--- a/entity/LetterRecipient_entity/LetterRecipient_entity.aod
+++ b/entity/LetterRecipient_entity/LetterRecipient_entity.aod
@@ -87,6 +87,10 @@
         </entityActionField>
       </children>
     </entityActionGroup>
+    <entityField>
+      <name>ADDRESS_ID</name>
+      <title>Address</title>
+    </entityField>
   </entityFields>
   <recordContainers>
     <dbRecordContainer>
@@ -159,6 +163,14 @@
           <name>TARGETCONTEXT.value</name>
           <expression>%aditoprj%/entity/LetterRecipient_entity/recordcontainers/db/recordfieldmappings/targetcontext.value/expression.js</expression>
         </dbRecordFieldMapping>
+        <dbRecordFieldMapping>
+          <name>ADDRESS_ID.displayValue</name>
+          <expression>%aditoprj%/entity/LetterRecipient_entity/recordcontainers/db/recordfieldmappings/address_id.displayvalue/expression.js</expression>
+        </dbRecordFieldMapping>
+        <dbRecordFieldMapping>
+          <name>ADDRESS_ID.value</name>
+          <recordfield>CONTACT.ADDRESS_ID</recordfield>
+        </dbRecordFieldMapping>
       </recordFieldMappings>
     </dbRecordContainer>
   </recordContainers>
diff --git a/entity/LetterRecipient_entity/recordcontainers/db/fromClauseProcess.js b/entity/LetterRecipient_entity/recordcontainers/db/fromClauseProcess.js
index 7abfb0194a..a1d94b7c23 100644
--- a/entity/LetterRecipient_entity/recordcontainers/db/fromClauseProcess.js
+++ b/entity/LetterRecipient_entity/recordcontainers/db/fromClauseProcess.js
@@ -2,4 +2,5 @@ import("system.result");
 
 result.string("LETTERRECIPIENT join CONTACT on LETTERRECIPIENT.CONTACT_ID = CONTACT.CONTACTID \
     left join PERSON on CONTACT.PERSON_ID = PERSON.PERSONID \
-    left join ORGANISATION on CONTACT.ORGANISATION_ID = ORGANISATION.ORGANISATIONID");
\ No newline at end of file
+    left join ORGANISATION on CONTACT.ORGANISATION_ID = ORGANISATION.ORGANISATIONID \
+    left join ADDRESS on (ADDRESS.ADDRESSID = CONTACT.ADDRESS_ID)");
\ No newline at end of file
diff --git a/entity/LetterRecipient_entity/recordcontainers/db/recordfieldmappings/address_id.displayvalue/expression.js b/entity/LetterRecipient_entity/recordcontainers/db/recordfieldmappings/address_id.displayvalue/expression.js
new file mode 100644
index 0000000000..beac43f3d9
--- /dev/null
+++ b/entity/LetterRecipient_entity/recordcontainers/db/recordfieldmappings/address_id.displayvalue/expression.js
@@ -0,0 +1,5 @@
+import("PostalAddress_lib");
+import("system.result");
+
+var res = AddressUtils.formatOnelineSql();
+result.string(res);
\ No newline at end of file
diff --git a/entity/Letter_entity/recordcontainers/jdito/onInsert.js b/entity/Letter_entity/recordcontainers/jdito/onInsert.js
index eeb73941cf..1248954c4e 100644
--- a/entity/Letter_entity/recordcontainers/jdito/onInsert.js
+++ b/entity/Letter_entity/recordcontainers/jdito/onInsert.js
@@ -3,6 +3,7 @@ import("ActivityTask_lib");
 import("system.neon");
 import("system.vars");
 import("DocumentTemplate_lib");
+import("KeywordRegistry_basic");
 
 var template = DocumentTemplate.loadTemplate(vars.get("$field.DOCUMENT_TEMPLATE"));
 var contactId = vars.get("$param.ContactId_param");
@@ -16,4 +17,4 @@ if (contactId)
     links.push([context, contactId]);
 }
 
-ActivityUtils.createNewActivity(null, links, null, null, [[template.filename, content, false]]);
+ActivityUtils.createNewActivity(null, links, null, null, [[template.filename, content, false]], $KeywordRegistry.activityDirection$outgoing());
diff --git a/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod b/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod
index 571792ff42..035f3b18e6 100644
--- a/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod
+++ b/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod
@@ -4848,6 +4848,12 @@
     <entry>
       <key>Should the mail be sent now?</key>
     </entry>
+    <entry>
+      <key>Add the selection to a bulk mail</key>
+    </entry>
+    <entry>
+      <key>Add the selection to a serial letter</key>
+    </entry>
   </keyValueMap>
   <font name="Dialog" style="0" size="11" />
   <sqlModels>
diff --git a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod
index 942137eb6c..114ef65cf9 100644
--- a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod
+++ b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod
@@ -58,6 +58,10 @@
       <key>MAX</key>
       <value>maximal</value>
     </entry>
+    <entry>
+      <key>Create activities</key>
+      <value>Aktivitäten erstellen</value>
+    </entry>
     <entry>
       <key>NONE</key>
       <value>keine</value>
diff --git a/language/_____LANGUAGE_en/_____LANGUAGE_en.aod b/language/_____LANGUAGE_en/_____LANGUAGE_en.aod
index da70638b8f..b8f7858125 100644
--- a/language/_____LANGUAGE_en/_____LANGUAGE_en.aod
+++ b/language/_____LANGUAGE_en/_____LANGUAGE_en.aod
@@ -4897,6 +4897,12 @@
     <entry>
       <key>Should the mail be sent now?</key>
     </entry>
+    <entry>
+      <key>Add the selection to a bulk mail</key>
+    </entry>
+    <entry>
+      <key>Add the selection to a serial letter</key>
+    </entry>
   </keyValueMap>
   <font name="Dialog" style="0" size="11" />
 </language>
diff --git a/neonContext/BulkMailStatusChart/BulkMailStatusChart.aod b/neonContext/BulkMailStatusChart/BulkMailStatusChart.aod
new file mode 100644
index 0000000000..da6eee8688
--- /dev/null
+++ b/neonContext/BulkMailStatusChart/BulkMailStatusChart.aod
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<neonContext xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.0" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonContext/1.1.0">
+  <name>BulkMailStatusChart</name>
+  <majorModelMode>DISTRIBUTED</majorModelMode>
+  <entity>BulkMailStatusChart_entity</entity>
+  <references>
+    <neonViewReference>
+      <name>403b6458-f106-436c-abf7-5620ecb42eae</name>
+      <view>BulkMailStatusChart_view</view>
+    </neonViewReference>
+  </references>
+</neonContext>
diff --git a/neonView/BulkMailEdit_view/BulkMailEdit_view.aod b/neonView/BulkMailEdit_view/BulkMailEdit_view.aod
index a827d94cd3..c0f679557d 100644
--- a/neonView/BulkMailEdit_view/BulkMailEdit_view.aod
+++ b/neonView/BulkMailEdit_view/BulkMailEdit_view.aod
@@ -37,6 +37,10 @@
           <name>e4ec09c2-3815-4a3b-bce8-c12d5b919b04</name>
           <entityField>SENDER</entityField>
         </entityFieldLink>
+        <entityFieldLink>
+          <name>d9b91083-948e-4a0f-a29c-4962ddd78b41</name>
+          <entityField>CREATEACTIVITIES</entityField>
+        </entityFieldLink>
         <entityFieldLink>
           <name>0a67f430-dbcd-4605-b626-ee6d715ab248</name>
           <entityField>content</entityField>
diff --git a/neonView/BulkMailPreview_view/BulkMailPreview_view.aod b/neonView/BulkMailPreview_view/BulkMailPreview_view.aod
index 1e7cc7611b..bd3f635140 100644
--- a/neonView/BulkMailPreview_view/BulkMailPreview_view.aod
+++ b/neonView/BulkMailPreview_view/BulkMailPreview_view.aod
@@ -6,6 +6,7 @@
     <headerFooterLayout>
       <name>layout</name>
       <header>Card</header>
+      <footer>6def3a7a-c9a0-4f2d-a36f-e53a631d8261</footer>
     </headerFooterLayout>
   </layout>
   <children>
@@ -42,7 +43,16 @@
           <name>8bb72d39-3348-4bd6-b57d-f7f5ae573e73</name>
           <entityField>DESCRIPTION</entityField>
         </entityFieldLink>
+        <entityFieldLink>
+          <name>514d0861-ad00-4d32-9c56-6be0443e03e3</name>
+          <entityField>CREATEACTIVITIES</entityField>
+        </entityFieldLink>
       </fields>
     </genericViewTemplate>
+    <neonViewReference>
+      <name>6def3a7a-c9a0-4f2d-a36f-e53a631d8261</name>
+      <entityField>RecipientStatusChart</entityField>
+      <view>BulkMailStatusChart_view</view>
+    </neonViewReference>
   </children>
 </neonView>
diff --git a/neonView/BulkMailStatusChart_view/BulkMailStatusChart_view.aod b/neonView/BulkMailStatusChart_view/BulkMailStatusChart_view.aod
new file mode 100644
index 0000000000..efd092ba46
--- /dev/null
+++ b/neonView/BulkMailStatusChart_view/BulkMailStatusChart_view.aod
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<neonView xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.2" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonView/1.1.2">
+  <name>BulkMailStatusChart_view</name>
+  <majorModelMode>DISTRIBUTED</majorModelMode>
+  <layout>
+    <noneLayout>
+      <name>layout</name>
+    </noneLayout>
+  </layout>
+  <children>
+    <singleDataChartViewTemplate>
+      <name>SingleDataChart</name>
+      <chartType>PIE</chartType>
+      <xAxis>X</xAxis>
+      <yAxis>Y</yAxis>
+      <entityField>#ENTITY</entityField>
+      <title>Recipients</title>
+    </singleDataChartViewTemplate>
+  </children>
+</neonView>
diff --git a/neonView/LetterRecipientFilter_view/LetterRecipientFilter_view.aod b/neonView/LetterRecipientFilter_view/LetterRecipientFilter_view.aod
index 3a4c82e844..5d453c6f01 100644
--- a/neonView/LetterRecipientFilter_view/LetterRecipientFilter_view.aod
+++ b/neonView/LetterRecipientFilter_view/LetterRecipientFilter_view.aod
@@ -24,6 +24,10 @@
           <name>037e6bac-1e49-4c89-ae72-a5c64b9261d0</name>
           <entityField>CONTACT_ID</entityField>
         </neonTableColumn>
+        <neonTableColumn>
+          <name>e4e4ac89-100c-4fb8-b365-3e8f909ca526</name>
+          <entityField>ADDRESS_ID</entityField>
+        </neonTableColumn>
       </columns>
     </tableViewTemplate>
   </children>
diff --git a/process/ActivityTask_lib/process.js b/process/ActivityTask_lib/process.js
index 75016636d7..dc1ac9e9af 100644
--- a/process/ActivityTask_lib/process.js
+++ b/process/ActivityTask_lib/process.js
@@ -138,9 +138,9 @@ ActivityUtils.insertDocuments = function (pActivityId, pDocuments)
 /**
  * Create a new activity
  */
-ActivityUtils.createNewActivity = function(pRowId, pAdditionalLinks, pParentContext, pParentId, pDocuments)
+ActivityUtils.createNewActivity = function(pRowId, pAdditionalLinks, pParentContext, pParentId, pDocuments, pDirection)
 {
-    _ActivityTaskUtils._createNew("Activity", pRowId, pAdditionalLinks, pParentContext, pParentId, null, pDocuments)
+    _ActivityTaskUtils._createNew("Activity", pRowId, pAdditionalLinks, pParentContext, pParentId, null, pDocuments, pDirection)
 }
 
 /*
@@ -246,7 +246,7 @@ function _ActivityTaskUtils() {}
  * Create a new task
  * @ignore
  */
-_ActivityTaskUtils._createNew = function(pContext, pRowId, pAdditionalLinks, pParentContext, pParentId, pParams, pDocuments)
+_ActivityTaskUtils._createNew = function(pContext, pRowId, pAdditionalLinks, pParentContext, pParentId, pParams, pDocuments, pDirection)
 {
     if (pAdditionalLinks == undefined)
         pAdditionalLinks = [];
@@ -274,6 +274,10 @@ _ActivityTaskUtils._createNew = function(pContext, pRowId, pAdditionalLinks, pPa
     
     if (pDocuments)
         params["PresetDocuments_param"] = JSON.stringify(pDocuments);
+    
+    if (pDirection)
+        params["Direction_param"] = pDirection;
+    
     neon.openContext(pContext, null, null, neon.OPERATINGSTATE_NEW, params);
 }
 
-- 
GitLab