diff --git a/.liquibase/Data_alias/basic/2020.2.0/add_VisitrecommendationStatus.xml b/.liquibase/Data_alias/basic/2020.2.0/add_VisitrecommendationStatus.xml
new file mode 100644
index 0000000000000000000000000000000000000000..a2bd036c1d4146eca31052f506caf7d3474ea35e
--- /dev/null
+++ b/.liquibase/Data_alias/basic/2020.2.0/add_VisitrecommendationStatus.xml
@@ -0,0 +1,10 @@
+<?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="c.wimmer" id="e4ab868a-6072-483c-abb3-db83ce162575">
+        <addColumn tableName="VISITRECOMMENDATION">
+            <column name="STATUS" type="CHAR(36)"/>
+	</addColumn>
+  </changeSet>
+</databaseChangeLog>
\ No newline at end of file
diff --git a/.liquibase/Data_alias/basic/2020.2.0/changelog.xml b/.liquibase/Data_alias/basic/2020.2.0/changelog.xml
index 44cb1109f9aa5a3e05c2928c4b593ac7b94b8960..ee4d7f91050523db74d422c05894dcafc868f284 100644
--- a/.liquibase/Data_alias/basic/2020.2.0/changelog.xml
+++ b/.liquibase/Data_alias/basic/2020.2.0/changelog.xml
@@ -18,4 +18,5 @@
     <include relativeToChangelogFile="true" file="insert_VisitPlanningAttribute.xml"/> 
     <include relativeToChangelogFile="true" file="insert_VisitPlanEntryStatusAppointment.xml"/> 
     <include relativeToChangelogFile="true" file="add_VisitPlanEntry.xml"/> 
+    <include relativeToChangelogFile="true" file="add_VisitrecommendationStatus.xml"/> 
 </databaseChangeLog>
diff --git a/.liquibase/Data_alias/basic/2020.2.0/insert_VisitPlanEntryStatusAppointment.xml b/.liquibase/Data_alias/basic/2020.2.0/insert_VisitPlanEntryStatusAppointment.xml
index dedfad0664f3e8da5d70b697ba966e0db08c217b..1319607baf5a5a22557f3482af094dba289f93bc 100644
--- a/.liquibase/Data_alias/basic/2020.2.0/insert_VisitPlanEntryStatusAppointment.xml
+++ b/.liquibase/Data_alias/basic/2020.2.0/insert_VisitPlanEntryStatusAppointment.xml
@@ -5,7 +5,7 @@
   <changeSet author="c.wimmer" id="b1bd94b5-5cef-450d-a1a3-c510984373e0">
         <insert tableName="AB_KEYWORD_ENTRY">
             <column name="AB_KEYWORD_ENTRYID" value="70f352e7-81dc-4d44-9f12-30bfc2cc39f1"/>
-            <column name="KEYID" value="VISITSTATUSAPPOINTMENTREQUESTED                  "/>
+            <column name="KEYID" value="VISITSTATUSAPPOINTMENTREQUESTED"/>
             <column name="TITLE" value="requested"/>
             <column name="CONTAINER" value="VisitPlanEntryStatusAppointment"/>
             <column name="SORTING" valueNumeric="0"/>
@@ -14,7 +14,7 @@
         </insert>
         <insert tableName="AB_KEYWORD_ENTRY">
             <column name="AB_KEYWORD_ENTRYID" value="1b6b5070-8028-42f9-abfd-ee64142801d1"/>
-            <column name="KEYID" value="VISITSTATUSAPPOINTMENTCONFIRMED                "/>
+            <column name="KEYID" value="VISITSTATUSAPPOINTMENTCONFIRMED"/>
             <column name="TITLE" value="confirmed"/>
             <column name="CONTAINER" value="VisitPlanEntryStatusAppointment"/>
             <column name="SORTING" valueNumeric="1"/>
diff --git a/aliasDefinition/Data_alias/Data_alias.aod b/aliasDefinition/Data_alias/Data_alias.aod
index 5d68313f1fa39def86761a231e2123169e3f6478..91e67429dc858bc10d1ed6bbf818c25d3e861951 100644
--- a/aliasDefinition/Data_alias/Data_alias.aod
+++ b/aliasDefinition/Data_alias/Data_alias.aod
@@ -14820,6 +14820,20 @@
                 <title></title>
                 <description></description>
               </entityFieldDb>
+              <entityFieldDb>
+                <name>STATUS</name>
+                <dbName></dbName>
+                <primaryKey v="false" />
+                <columnType v="1" />
+                <size v="36" />
+                <scale v="0" />
+                <notNull v="false" />
+                <isUnique v="false" />
+                <index v="false" />
+                <documentation></documentation>
+                <title></title>
+                <description></description>
+              </entityFieldDb>
             </entityFields>
           </entityDb>
           <entityDb>
@@ -15070,6 +15084,20 @@
                 <title></title>
                 <description></description>
               </entityFieldDb>
+              <entityFieldDb>
+                <name>STATUS_APPOINTMENT</name>
+                <dbName></dbName>
+                <primaryKey v="false" />
+                <columnType v="12" />
+                <size v="36" />
+                <scale v="0" />
+                <notNull v="false" />
+                <isUnique v="false" />
+                <index v="false" />
+                <documentation></documentation>
+                <title></title>
+                <description></description>
+              </entityFieldDb>
             </entityFields>
           </entityDb>
           <entityDb>
diff --git a/entity/Activity_entity/recordcontainers/db/onDBInsert.js b/entity/Activity_entity/recordcontainers/db/onDBInsert.js
index c50343f5ee151ae93ea0838053e69c138540a21b..488c561a6ef3f60dbaf040c3bdd55673fad9df5a 100644
--- a/entity/Activity_entity/recordcontainers/db/onDBInsert.js
+++ b/entity/Activity_entity/recordcontainers/db/onDBInsert.js
@@ -28,8 +28,12 @@ if(vars.exists("$param.VisitPlanEntryId_param") && vars.get("$param.VisitPlanEnt
 {    
     var values = [$KeywordRegistry.visitPlanEntryStatus$Visitreportcreated()];
     var columns = ["STATUS"];
-    var update = newWhere("VISITPLANENTRY.VISITPLANENTRYID", vars.get("$param.VisitPlanEntryId_param"))
+    var updateEntry = newWhere("VISITPLANENTRY.VISITPLANENTRYID", vars.get("$param.VisitPlanEntryId_param"))
                             .updateData(true, "VISITPLANENTRY", columns, null, values);
+                            
+    var recommendationId = newSelect("VISITPLANENTRY.VISITRECOMMENDATION_ID").from("VISITPLANENTRY").where("VISITPLANENTRY.VISITPLANENTRYID", vars.get("$param.VisitPlanEntryId_param"))
+    var updateRecommendation = newWhere("VISITRECOMMENDATION.VISITRECOMMENDATIONID", recommendationId)
+                                .updateData(true, "VISITRECOMMENDATION", ["STATUS"], null, [$KeywordRegistry.visitPlanEntryStatus$Visitreportcreated()])
 }
 
 if (vars.exists("$param.InsertLinks_param") && vars.get("$param.InsertLinks_param"))
diff --git a/entity/VisitPlanEntry_entity/VisitPlanEntry_entity.aod b/entity/VisitPlanEntry_entity/VisitPlanEntry_entity.aod
index b54657f204dd799b9132a76f8f003e19493f47ed..b640c523a50c0f5ab6bd1a30a7f71ad6015ec7cd 100644
--- a/entity/VisitPlanEntry_entity/VisitPlanEntry_entity.aod
+++ b/entity/VisitPlanEntry_entity/VisitPlanEntry_entity.aod
@@ -171,6 +171,7 @@
     </entityField>
     <entityField>
       <name>VISITRECOMMENDATION_ID</name>
+      <valueProcess>%aditoprj%/entity/VisitPlanEntry_entity/entityfields/visitrecommendation_id/valueProcess.js</valueProcess>
     </entityField>
     <entityField>
       <name>APPOINTMENT_ID</name>
@@ -267,6 +268,10 @@
         </entityParameter>
       </children>
     </entityConsumer>
+    <entityParameter>
+      <name>VisitrecommendationId_param</name>
+      <expose v="true" />
+    </entityParameter>
   </entityFields>
   <recordContainers>
     <jDitoRecordContainer>
@@ -329,6 +334,9 @@
         <jDitoRecordFieldMapping>
           <name>STATUS_APPOINTMENT.displayValue</name>
         </jDitoRecordFieldMapping>
+        <jDitoRecordFieldMapping>
+          <name>VISITRECOMMENDATION_ID.value</name>
+        </jDitoRecordFieldMapping>
       </recordFieldMappings>
     </jDitoRecordContainer>
   </recordContainers>
diff --git a/entity/VisitPlanEntry_entity/afterSave.js b/entity/VisitPlanEntry_entity/afterSave.js
index 3da64c391a56cbba85a9e49a5deb765759d8dc89..965057b26347f4a4dfbfd2dbe487c80b0d799352 100644
--- a/entity/VisitPlanEntry_entity/afterSave.js
+++ b/entity/VisitPlanEntry_entity/afterSave.js
@@ -8,11 +8,18 @@ import("system.neon");
 import("system.calendars");
 import("system.util");
 import("system.vars");
+import("system.db");
 import("Calendar_lib");
 import("Communication_lib");
 
 var savedData = vars.get("$local.entitydata");
-if(savedData["STATUS_APPOINTMENT"] == "VISITSTATUSAPPOINTMENTCONFIRMED     ")
+
+if(savedData["VISITRECOMMENDATION_ID"])
+{
+    db.updateData("VISITRECOMMENDATION", ["STATUS"], db.getColumnTypes("VISITRECOMMENDATION", ["STATUS"]), ["PLANNED"]
+                , "VISITRECOMMENDATIONID = '" + savedData["VISITRECOMMENDATION_ID"] + "'");
+}
+if(savedData["STATUS_APPOINTMENT"] == "VISITSTATUSAPPOINTMENTCONFIRMED")
 {
     var summary = translate.text("Besuch vor Ort") + " | " + savedData["CONTACT_ID.displayValue"];
     var description = savedData["CONTACT_ID.displayValue"];
@@ -35,4 +42,4 @@ if(savedData["STATUS_APPOINTMENT"] == "VISITSTATUSAPPOINTMENTCONFIRMED     ")
     
     neon.openContext("Appointment", "AppointmentEdit_view", [vars.get("$field.UID")], neon.OPERATINGSTATE_NEW, params, null);
     result.string(true);
-}
\ No newline at end of file
+}
diff --git a/entity/VisitPlanEntry_entity/entityfields/entityactiongroup/children/newactivity/onActionProcess.js b/entity/VisitPlanEntry_entity/entityfields/entityactiongroup/children/newactivity/onActionProcess.js
index cf6d64f699421bf5436f5e72b9c4d1d5d39c0a68..9c215fd3ee4f53ee55b7558fa704565a87ecffc3 100644
--- a/entity/VisitPlanEntry_entity/entityfields/entityactiongroup/children/newactivity/onActionProcess.js
+++ b/entity/VisitPlanEntry_entity/entityfields/entityactiongroup/children/newactivity/onActionProcess.js
@@ -19,7 +19,6 @@ var pointOfContact = newSelect("CONTACT.CONTACTID", db.getCurrentAlias())
                                 .where("AB_ATTRIBUTE.AB_ATTRIBUTEID", $AttributeRegistry.visitPlanPointOfContact()) 
                                 .and("CONTACT.CONTACTID", vars.get("$field.ORGANISATION_CONTACT_ID"))
                                 .cell();
-var context;
 
 if(pointOfContact)
     links.push([ContactUtils.getContextByContactId(pointOfContact), pointOfContact]);
@@ -30,3 +29,4 @@ else
 }
 
 ActivityUtils.createNewActivity(null, links, null, null, null, null, $KeywordRegistry.activityDirection$outgoing(), null, $KeywordRegistry.activityCategory$visit(), vars.get("$field.ENTRYDATE"), vars.get("$field.UID"));
+
diff --git a/entity/VisitPlanEntry_entity/entityfields/visitrecommendation_id/valueProcess.js b/entity/VisitPlanEntry_entity/entityfields/visitrecommendation_id/valueProcess.js
new file mode 100644
index 0000000000000000000000000000000000000000..ae46228cf2b97b28333d001e095c9609b43fee70
--- /dev/null
+++ b/entity/VisitPlanEntry_entity/entityfields/visitrecommendation_id/valueProcess.js
@@ -0,0 +1,7 @@
+import("system.logging");
+import("system.neon");
+import("system.result");
+import("system.vars");
+
+if (vars.get("$sys.operatingstate") == neon.OPERATINGSTATE_NEW && vars.get("$this.value")== null)
+    result.string(vars.get("$param.VisitrecommendationId_param"));
\ No newline at end of file
diff --git a/entity/VisitPlanEntry_entity/recordcontainers/jdito/contentProcess.js b/entity/VisitPlanEntry_entity/recordcontainers/jdito/contentProcess.js
index c0c4fd38cfa1d17138f24fc2649119c04fd83569..698efff837c96b3f967440cee3cb81a3a078b768 100644
--- a/entity/VisitPlanEntry_entity/recordcontainers/jdito/contentProcess.js
+++ b/entity/VisitPlanEntry_entity/recordcontainers/jdito/contentProcess.js
@@ -16,7 +16,8 @@ var items = [];
 var group = [];
 var entryData = "";
 
-var entrySQL = newSelect("ENTRYDATE, VISITPLANENTRYID, BEGIN_TIME, END_TIME, ORGANISATION_CONTACT_ID, CONTACT_ID,STATUS, VISITPLANEMPLOYEEWEEK_ID, APPOINTMENT_ID, STATUS_APPOINTMENT")
+var entrySQL = newSelect("ENTRYDATE, VISITPLANENTRYID, BEGIN_TIME, END_TIME, ORGANISATION_CONTACT_ID, CONTACT_ID,STATUS, VISITPLANEMPLOYEEWEEK_ID"
+                        +", APPOINTMENT_ID, STATUS_APPOINTMENT, VISITRECOMMENDATION_ID")
                             .from("VISITPLANENTRY");
 
 if (vars.exists("$local.idvalues") && vars.get("$local.idvalues"))
@@ -46,8 +47,8 @@ if(entryData.length > 0)
 {
     for(var i = 0; i < entryData.length; i++)
     {
-        var entryDateRaw, visitPlanEntryId, beginn_time, end_time, organisationContact_id, contact_id, status, visitplanemployeeweek_id, appointmentid, statusAppointment;
-        [entryDateRaw, visitPlanEntryId, beginn_time, end_time, organisationContact_id, contact_id, status, visitplanemployeeweek_id, appointmentid, statusAppointment] = entryData[i]
+        var entryDateRaw, visitPlanEntryId, beginn_time, end_time, organisationContact_id, contact_id, status, visitplanemployeeweek_id, appointmentid, statusAppointment, visitrecommendation_id;
+        [entryDateRaw, visitPlanEntryId, beginn_time, end_time, organisationContact_id, contact_id, status, visitplanemployeeweek_id, appointmentid, statusAppointment, visitrecommendation_id] = entryData[i]
         
         var contactname = db.cell(PersUtils.getResolvingDisplaySubSql("'" + contact_id + "'"));
         var orgname = OrganisationUtils.getNameByContactId(organisationContact_id);
@@ -60,13 +61,13 @@ if(entryData.length > 0)
 
         items.push([visitPlanEntryId, false, parentName + "#" + entryDate, "",  beginn_time
             , end_time, organisationContact_id, orgname, contact_id, contactname, entryDateRaw, status, visitplanemployeeweek_id, appointmentid
-            , statusDisplay, statusAppointment, statusAppointmentDisplay]);
+            , statusDisplay, statusAppointment, statusAppointmentDisplay, visitrecommendation_id]);
 
         if(!vars.get("$local.idvalues"))
         {
             if(group.indexOf(parentName + "#" + entryDate) == -1)
             {
-                items.push([parentName + "#" + entryDate, true, "", parentName + " " + entryDate, "", "",  "", "", "", "", "", "", "", "", "", "", ""]);
+                items.push([parentName + "#" + entryDate, true, "", parentName + " " + entryDate, "", "",  "", "", "", "", "", "", "", "", "", "", "", ""]);
                 group.push(parentName + "#" + entryDate);
             }
         }
diff --git a/entity/VisitPlanEntry_entity/recordcontainers/jdito/onDelete.js b/entity/VisitPlanEntry_entity/recordcontainers/jdito/onDelete.js
index a507271c6792ee838fad76db423cae2fb2209c8b..21a2ce7d36ca4ec834da97971295351836ace21c 100644
--- a/entity/VisitPlanEntry_entity/recordcontainers/jdito/onDelete.js
+++ b/entity/VisitPlanEntry_entity/recordcontainers/jdito/onDelete.js
@@ -5,6 +5,10 @@ import("Sql_lib");
 import("system.db");
 
 var id = vars.get("$field.APPOINTMENT_ID") //deletes appointmententries (+ the linked Objects) if an appointment has been made
+var recommendationId = vars.get("$field.VISITRECOMMENDATION_ID");
+
+db.updateData("VISITRECOMMENDATION", ["STATUS"], db.getColumnTypes("VISITRECOMMENDATION", ["STATUS"]), [""]
+                , "VISITRECOMMENDATIONID = '" + recommendationId + "'");
 
 new SqlBuilder(SqlUtils.getSystemAlias()).whereIfSet("ASYS_CALENDARBACKEND.ELEMENTUID", id)
     .deleteData();
@@ -13,4 +17,5 @@ newWhereIfSet("AB_APPOINTMENTLINK.APPOINTMENT_ID", id)
     .deleteData();
 
 newWhereIfSet("VISITPLANENTRY.VISITPLANENTRYID", "$field.UID")
-    .deleteData();
\ No newline at end of file
+    .deleteData();
+    
diff --git a/entity/VisitPlanEntry_entity/recordcontainers/jdito/onInsert.js b/entity/VisitPlanEntry_entity/recordcontainers/jdito/onInsert.js
index 3af61132d2661e233243ae7487e206ff308048a7..c9f89a1065270df5b8602b0a086d052662774858 100644
--- a/entity/VisitPlanEntry_entity/recordcontainers/jdito/onInsert.js
+++ b/entity/VisitPlanEntry_entity/recordcontainers/jdito/onInsert.js
@@ -50,7 +50,8 @@ else
 }
 
 var rowData = vars.get("$local.rowdata");
-
+//logging.log("rowData: " + rowData["VISITRECOMMENDATION_ID.value"]);
+//logging.log("field: " +vars.get("$field.VISITRECOMMENDATION_ID"));
 var valuesEntry = [
     rowData["UID.value"],
     rowData["ENTRYDATE.value"],
@@ -60,7 +61,8 @@ var valuesEntry = [
     rowData["CONTACT_ID.value"],
     visitPlanEmployeeWeekID,
     rowData["STATUS.value"],
-    rowData["STATUS_APPOINTMENT.value"]
+    rowData["STATUS_APPOINTMENT.value"],
+    rowData["VISITRECOMMENDATION_ID.value"] || ""
 ];
 
 var columnsEntry = [
@@ -72,7 +74,8 @@ var columnsEntry = [
     "CONTACT_ID",
     "VISITPLANEMPLOYEEWEEK_ID",
     "STATUS",
-    "STATUS_APPOINTMENT"
+    "STATUS_APPOINTMENT",
+    "VISITRECOMMENDATION_ID"
 ];
 
 insertData.push(["VISITPLANENTRY", columnsEntry, null, valuesEntry])
diff --git a/entity/VisitRecommendation_entity/VisitRecommendation_entity.aod b/entity/VisitRecommendation_entity/VisitRecommendation_entity.aod
index df6cefb68008a79673c637bad54ed142c33e0738..10c06c68da94fe7ce03e752c4efc83add3dc1031 100644
--- a/entity/VisitRecommendation_entity/VisitRecommendation_entity.aod
+++ b/entity/VisitRecommendation_entity/VisitRecommendation_entity.aod
@@ -234,6 +234,9 @@
       <title>City</title>
       <groupable v="true" />
     </entityField>
+    <entityField>
+      <name>STATUS</name>
+    </entityField>
   </entityFields>
   <recordContainers>
     <jDitoRecordContainer>
diff --git a/entity/VisitRecommendation_entity/entityfields/newentrygroup/children/newvisitplaneentry/onActionProcess.js b/entity/VisitRecommendation_entity/entityfields/newentrygroup/children/newvisitplaneentry/onActionProcess.js
index 566fb7f1a7be86a67996e8cad504c1e165c51f87..e5ac707432897a4fca32c7d98e93f4deea37f655 100644
--- a/entity/VisitRecommendation_entity/entityfields/newentrygroup/children/newvisitplaneentry/onActionProcess.js
+++ b/entity/VisitRecommendation_entity/entityfields/newentrygroup/children/newvisitplaneentry/onActionProcess.js
@@ -9,5 +9,6 @@ params["NoVisitPlanEmployeeWeek_param"] = true;
 params["ComingFromRecommendation_param"] = true;
 params["ContactId_param"] = vars.get("$field.CONTACT_PERSON_ID");
 params["Entrydate_param"] = vars.get("$field.DUE_DATE");
+params["VisitrecommendationId_param"] = vars.get("$field.UID");
 
 neon.openContext("VisitPlanEntry", null, null, neon.OPERATINGSTATE_NEW, params);
\ No newline at end of file
diff --git a/entity/VisitRecommendation_entity/recordcontainers/jdito/contentProcess.js b/entity/VisitRecommendation_entity/recordcontainers/jdito/contentProcess.js
index d2235a8b3157ce540cc9bd83ba5fd4415da960c0..56bfedc1d072a7ae4bc1fd18318424d952507e62 100644
--- a/entity/VisitRecommendation_entity/recordcontainers/jdito/contentProcess.js
+++ b/entity/VisitRecommendation_entity/recordcontainers/jdito/contentProcess.js
@@ -36,11 +36,12 @@ var recommendationSQLData = newSelect(
                                 "ADDRESS.CITY",                         //9
                                 "VISITRECOMMENDATION.USER_NEW",         //10
                                 "VISITRECOMMENDATION.CONTACT_PERSON_ID",//11
-                                "VISITRECOMMENDATION.RESPONSIBLE"       //12
+                                "VISITRECOMMENDATION.RESPONSIBLE",      //12
                             ]) 
                             .from("VISITRECOMMENDATION")
                             .join("CONTACT", "coalesce(VISITRECOMMENDATION.CONTACT_PERSON_ID, VISITRECOMMENDATION.CONTACT_ID) = CONTACT.CONTACTID")
                             .leftJoin("ADDRESS", "CONTACT.ADDRESS_ID = ADDRESS.ADDRESSID")
+                            .where("VISITRECOMMENDATION.STATUS is null")
 
 
 var idValues = false;
@@ -48,7 +49,7 @@ if (vars.exists("$local.idvalues") && vars.get("$local.idvalues"))
     idValues = true;
 
 if(idValues == true)
-    recommendationSQLData.where("VISITRECOMMENDATION.VISITRECOMMENDATIONID", vars.get("$local.idvalues"), SqlBuilder.IN())
+    recommendationSQLData.and("VISITRECOMMENDATION.VISITRECOMMENDATIONID", vars.get("$local.idvalues"), SqlBuilder.IN())
 
 recommendationSQLData = recommendationSQLData.table();
 
@@ -83,7 +84,29 @@ for( let i = 0; i < recommendationSQLData.length; i++)
     tmpData[17] = ContactUtils.getFullTitleByContactId(recommendationSQLData[i][12], false); //RESPONSIBLE.displayvalue
     tmpData[18] = recommendationSQLData[i][12]; //RESPONSIBLE.value
     
-    recommendationData.push(tmpData);
+//    if(recommendationSQLData[i][13] == "1")
+//    {
+//        var visitEntries = newSelect(["ORGANISATION_CONTACT_ID", "CONTACT_ID", "ENTRYDATE"]).from("VISITPLANENTRY").where("VISITPLANENTRY.VISITRECOMMENDATION_ID", tmpData[0]).arrayRow();
+//
+//        var act = newSelect("ACTIVITY.ACTIVITYID")
+//              .from("ACTIVITY")
+//              .join("ACTIVITYLINK", "ACTIVITY.ACTIVITYID = ACTIVITYLINK.ACTIVITY_ID")
+//              .where("ACTIVITY.CATEGORY", "VISIT")
+//              .and("ACTIVITY.ENTRYDATE", visitEntries[2])
+//              .and("ACTIVITYLINK.OBJECT_ROWID", [visitEntries[1], visitEntries[0]])
+//              .cell();
+//              
+//        var entryWeek = datetime.toDate(visitEntries[2], "w");
+//        var currentWeek = datetime.toDate(vars.get("$sys.date"), "w")
+//        if(!act && (entryWeek < currentWeek))
+//        {
+//            recommendationData.push(tmpData);
+//        }
+//    }
+//    else
+//        recommendationData.push(tmpData);
+
+      recommendationData.push(tmpData);
 }
 
 //===========Visitfrequency============
@@ -100,7 +123,7 @@ if(idValues == false)
     activitySubQuery = newSelect("max(ENTRYDATE)")
                         .from("ACTIVITY")
                         .join("ACTIVITYLINK", "ACTIVITYID = ACTIVITY_ID")
-                        .where("ACTIVITYLINK.OBJECT_ROWID = org.ORGANISATIONID")
+                        .where("ACTIVITYLINK.OBJECT_ROWID = CONTACT.CONTACTID")
                         .and("ACTIVITY.CATEGORY", "VISIT")
 
     var visitFrequencyData = newSelect(["''"    //0
@@ -111,7 +134,7 @@ if(idValues == false)
                                                 .leftJoin("AB_ATTRIBUTE", "AB_ATTRIBUTE.AB_ATTRIBUTEID = AB_ATTRIBUTERELATION.AB_ATTRIBUTE_ID")
                                                 .leftJoin("ORGANISATION", "ORGANISATION.ORGANISATIONID = CONTACT.ORGANISATION_ID")
                                                 .where("AB_ATTRIBUTE.AB_ATTRIBUTEID", $AttributeRegistry.visitPlanPointOfContact())
-                                                .toString() + 
+                                                + 
                                             ")"            //2
                                         ,"ADDRESS.ADDRESS" //3
                                         ,"ADDRESS.COUNTRY" //4
@@ -183,6 +206,14 @@ if(idValues == false)
         tmpData[8] = KeywordUtils.getViewValue($KeywordRegistry.visitRecommendationPriority(), tmpData[6]) //PRIORITY.displayValue
         tmpData[9] = dueDate; //DUE_DATE.value
         
+        var manualRec = newSelect("STATUS")
+        .from("VISITRECOMMENDATION")
+        .where("VISITRECOMMENDATION.CONTACT_ID", visitFrequencyData[i][1])
+        .or("VISITRECOMMENDATION.CONTACT_PERSON_ID", visitFrequencyData[i][1])
+        .cell()
+
+        if(manualRec == "VISITSTATUSREPORTCREATED            ")
+            recommendationData.push(tmpData);
     }
 }