From 4446c7d6df37eab0bf1fd4e6e719d9959c09309d Mon Sep 17 00:00:00 2001
From: Sebastian Listl <s.listl@adito.de>
Date: Wed, 4 Nov 2020 10:39:24 +0100
Subject: [PATCH] #1065236 marketing automation workflow set adito url

---
 .../processvariables_param/valueProcess.js     |  3 ++-
 .../Organisation_entity.aod                    | 18 ++++++------------
 .../startmarketingworkflows/onActionProcess.js |  0
 .../WorkflowLauncher_entity.aod                |  2 ++
 .../OrganisationFilter_view.aod                |  2 --
 process/FilterViewAction_lib/process.js        |  2 +-
 process/SendEmail_workflowService/process.js   | 13 +++++++++----
 7 files changed, 20 insertions(+), 20 deletions(-)
 rename entity/Organisation_entity/entityfields/{workflowactions => filterviewactiongroup}/children/startmarketingworkflows/onActionProcess.js (100%)

diff --git a/entity/MarketingWorkflowLauncher_entity/entityfields/workflowlauncherintegration/children/processvariables_param/valueProcess.js b/entity/MarketingWorkflowLauncher_entity/entityfields/workflowlauncherintegration/children/processvariables_param/valueProcess.js
index 3855fc6c443..cea637a710a 100644
--- a/entity/MarketingWorkflowLauncher_entity/entityfields/workflowlauncherintegration/children/processvariables_param/valueProcess.js
+++ b/entity/MarketingWorkflowLauncher_entity/entityfields/workflowlauncherintegration/children/processvariables_param/valueProcess.js
@@ -2,6 +2,7 @@ import("system.vars");
 import("system.result");
 
 var variables = {
-    documentTemplateId: vars.get("$field.DOCUMENTTEMPLATE_ID")
+    documentTemplateId: vars.get("$field.DOCUMENTTEMPLATE_ID"),
+    originUrl: vars.get("$sys.origin")
 };
 result.string(JSON.stringify(variables));
\ No newline at end of file
diff --git a/entity/Organisation_entity/Organisation_entity.aod b/entity/Organisation_entity/Organisation_entity.aod
index bfd5e70a02a..d428c6f4de9 100644
--- a/entity/Organisation_entity/Organisation_entity.aod
+++ b/entity/Organisation_entity/Organisation_entity.aod
@@ -959,6 +959,12 @@
           <tooltip>Export fields of this table</tooltip>
           <tooltipProcess>%aditoprj%/entity/Organisation_entity/entityfields/filterviewactiongroup/children/export/tooltipProcess.js</tooltipProcess>
         </entityActionField>
+        <entityActionField>
+          <name>startMarketingWorkflows</name>
+          <title>Start marketing workflow</title>
+          <onActionProcess>%aditoprj%/entity/Organisation_entity/entityfields/filterviewactiongroup/children/startmarketingworkflows/onActionProcess.js</onActionProcess>
+          <isObjectAction v="false" />
+        </entityActionField>
       </children>
     </entityActionGroup>
     <entityActionField>
@@ -1422,18 +1428,6 @@
         <fieldName>FilterProvider</fieldName>
       </dependency>
     </entityConsumer>
-    <entityActionGroup>
-      <name>workflowActions</name>
-      <title>Workflow</title>
-      <children>
-        <entityActionField>
-          <name>startMarketingWorkflows</name>
-          <title>Start marketing workflow</title>
-          <onActionProcess>%aditoprj%/entity/Organisation_entity/entityfields/workflowactions/children/startmarketingworkflows/onActionProcess.js</onActionProcess>
-          <isObjectAction v="false" />
-        </entityActionField>
-      </children>
-    </entityActionGroup>
   </entityFields>
   <recordContainers>
     <dbRecordContainer>
diff --git a/entity/Organisation_entity/entityfields/workflowactions/children/startmarketingworkflows/onActionProcess.js b/entity/Organisation_entity/entityfields/filterviewactiongroup/children/startmarketingworkflows/onActionProcess.js
similarity index 100%
rename from entity/Organisation_entity/entityfields/workflowactions/children/startmarketingworkflows/onActionProcess.js
rename to entity/Organisation_entity/entityfields/filterviewactiongroup/children/startmarketingworkflows/onActionProcess.js
diff --git a/entity/WorkflowLauncher_entity/WorkflowLauncher_entity.aod b/entity/WorkflowLauncher_entity/WorkflowLauncher_entity.aod
index f1640dc1aac..4ac6aa0edf3 100644
--- a/entity/WorkflowLauncher_entity/WorkflowLauncher_entity.aod
+++ b/entity/WorkflowLauncher_entity/WorkflowLauncher_entity.aod
@@ -31,6 +31,7 @@
       <name>KEY</name>
       <title>Key</title>
       <consumer>WorkflowDefinitions</consumer>
+      <mandatory v="true" />
       <state>EDITABLE</state>
     </entityField>
     <entityActionField>
@@ -88,6 +89,7 @@
   <recordContainers>
     <datalessRecordContainer>
       <name>dataLess</name>
+      <alias>Data_alias</alias>
     </datalessRecordContainer>
   </recordContainers>
 </entity>
diff --git a/neonView/OrganisationFilter_view/OrganisationFilter_view.aod b/neonView/OrganisationFilter_view/OrganisationFilter_view.aod
index 7f17a0e1a0f..1cbde0c5309 100644
--- a/neonView/OrganisationFilter_view/OrganisationFilter_view.aod
+++ b/neonView/OrganisationFilter_view/OrganisationFilter_view.aod
@@ -51,7 +51,6 @@
       <name>Organisations</name>
       <favoriteActionGroup1>filterViewActionGroup</favoriteActionGroup1>
       <favoriteActionGroup2>DuplicateActions</favoriteActionGroup2>
-      <favoriteActionGroup3>workflowActions</favoriteActionGroup3>
       <subtitleField>CUSTOMERCODE_DISPLAY_fieldGroup</subtitleField>
       <entityField>#ENTITY</entityField>
       <linkedColumns>
@@ -101,7 +100,6 @@
       <name>Treetable</name>
       <favoriteActionGroup1>filterViewActionGroup</favoriteActionGroup1>
       <favoriteActionGroup2>DuplicateActions</favoriteActionGroup2>
-      <favoriteActionGroup3>workflowActions</favoriteActionGroup3>
       <entityField>#ENTITY</entityField>
       <linkedColumns>
         <element>NAME</element>
diff --git a/process/FilterViewAction_lib/process.js b/process/FilterViewAction_lib/process.js
index 8615c426d6d..afd89d4d6d4 100644
--- a/process/FilterViewAction_lib/process.js
+++ b/process/FilterViewAction_lib/process.js
@@ -40,7 +40,7 @@ FilterViewActionUtils.getUidsByEntityFilter = function (pContext, pFilter)
     {
         return new SqlBuilder()
             .selectDistinct("CONTACT.CONTACTID")
-            .from("PERSON")
+            .from("ORGANISATION")
             .join("CONTACT", newWhere("ORGANISATION.ORGANISATIONID = CONTACT.ORGANISATION_ID").and("CONTACT.PERSON_ID is null"))
             .leftJoin("ADDRESS", "ADDRESS.ADDRESSID = CONTACT.ADDRESS_ID")
             .leftJoin("CLASSIFICATIONSTORAGE", "CLASSIFICATIONSTORAGE.OBJECT_ROWID = CONTACT.CONTACTID")
diff --git a/process/SendEmail_workflowService/process.js b/process/SendEmail_workflowService/process.js
index ded2b169e19..14247ad4e4b 100644
--- a/process/SendEmail_workflowService/process.js
+++ b/process/SendEmail_workflowService/process.js
@@ -14,15 +14,20 @@ var recipientContactId = variables.recipientContactId || variables.targetId;
 var documentTemplateId = variables.documentTemplateId;
 var senderName = variables.senderName;
 var mailSubject = variables.mailSubject;
+var aditoUrl = variables.originUrl;
 
 var actionParams = Utils.clone(variables);
 actionParams.processInstanceId = processInstanceId;
-var linkPlaceholder = new Placeholder("workflowActionLink", Placeholder.types.CALLBACKFUNCTION, function ()
+var additionalPlaceholders = [];
+if (aditoUrl)
 {
-    return WorkflowLinkActions.getActionLink("https://localhost:8443", actionParams.linkActionType, actionParams.redirectLink, actionParams);
-});
+    additionalPlaceholders.push(linkPlaceholder = new Placeholder("workflowActionLink", Placeholder.types.CALLBACKFUNCTION, function ()
+    {
+        return WorkflowLinkActions.getActionLink(aditoUrl, actionParams.linkActionType, actionParams.redirectLink, actionParams);
+    }));
+}
 
-var email = Email.fromTemplate(documentTemplateId, recipientContactId, null, [linkPlaceholder]);
+var email = Email.fromTemplate(documentTemplateId, recipientContactId, null, additionalPlaceholders);
 email.subject = mailSubject;
 email.toRecipients = [CommUtil.getStandardMail(recipientContactId)];
 
-- 
GitLab