diff --git a/entity/VisitRecommendation_entity/VisitRecommendation_entity.aod b/entity/VisitRecommendation_entity/VisitRecommendation_entity.aod index 3ee0de7653f8009d2421de1934f78fed9e9285c5..f545f2733aa235f1ce467dedbff0d4bf09f0d72a 100644 --- a/entity/VisitRecommendation_entity/VisitRecommendation_entity.aod +++ b/entity/VisitRecommendation_entity/VisitRecommendation_entity.aod @@ -13,7 +13,7 @@ <entityProvider> <name>#PROVIDER</name> <targetContextField>TARGET_CONTEXT</targetContextField> - <targetIdField>CONTACT_ID</targetIdField> + <targetIdField>TARGET_ID</targetIdField> <documentation>%aditoprj%/entity/VisitRecommendation_entity/entityfields/#provider/documentation.adoc</documentation> <dependencies> <entityDependency> @@ -167,6 +167,7 @@ <description></description> <consumer>PersonConsumer</consumer> <groupable v="true" /> + <linkedContext>Person</linkedContext> <valueProcess>%aditoprj%/entity/VisitRecommendation_entity/entityfields/contact_person_id/valueProcess.js</valueProcess> <displayValueProcess>%aditoprj%/entity/VisitRecommendation_entity/entityfields/contact_person_id/displayValueProcess.js</displayValueProcess> </entityField> @@ -237,6 +238,10 @@ <entityField> <name>STATUS</name> </entityField> + <entityField> + <name>TARGET_ID</name> + <valueProcess>%aditoprj%/entity/VisitRecommendation_entity/entityfields/target_id/valueProcess.js</valueProcess> + </entityField> </entityFields> <recordContainers> <jDitoRecordContainer> diff --git a/entity/VisitRecommendation_entity/entityfields/target_context/valueProcess.js b/entity/VisitRecommendation_entity/entityfields/target_context/valueProcess.js index a16a18c5851a7581712372aa29616de6b8ea61af..2899d9fff95bf928083f552f5b71d35327b7009b 100644 --- a/entity/VisitRecommendation_entity/entityfields/target_context/valueProcess.js +++ b/entity/VisitRecommendation_entity/entityfields/target_context/valueProcess.js @@ -1,3 +1,7 @@ +import("system.vars"); import("system.result"); -result.string("Organisation") \ No newline at end of file +if(vars.get("$field.CONTACT_PERSON_ID")) + result.string("Person") +else + result.string("Organisation") \ No newline at end of file diff --git a/entity/VisitRecommendation_entity/entityfields/target_id/valueProcess.js b/entity/VisitRecommendation_entity/entityfields/target_id/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..b68d32e6889172a4a1710a2ea1a45875faadf869 --- /dev/null +++ b/entity/VisitRecommendation_entity/entityfields/target_id/valueProcess.js @@ -0,0 +1,7 @@ +import("system.result"); +import("system.vars"); + +if(vars.get("$field.CONTACT_PERSON_ID")) + result.string(vars.get("$field.CONTACT_PERSON_ID")) +else + result.string(vars.get("$field.CONTACT_ID")) \ 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 e10e6cfdf7194409263af195e65a3f25f69863d2..6503563c54305abd903d89b573af29252732258c 100644 --- a/entity/VisitRecommendation_entity/recordcontainers/jdito/contentProcess.js +++ b/entity/VisitRecommendation_entity/recordcontainers/jdito/contentProcess.js @@ -105,7 +105,7 @@ if(idValues == false) .and("ACTIVITY.CATEGORY", "VISIT") var visitFrequencyData = newSelect(["''" //0 - , "CONTACT.CONTACTID" //1 + , "CONTACT.CONTACTID" //1 , "(" + newSelect("CONTACT.CONTACTID") .from("CONTACT") .leftJoin("AB_ATTRIBUTERELATION", "CONTACT.CONTACTID = AB_ATTRIBUTERELATION.OBJECT_ROWID") @@ -120,7 +120,9 @@ if(idValues == false) ,"ADDRESS.CITY" //6 , "visitPlanFrequency.ID_VALUE"//7 , activitySubQuery //8 - , "org.NAME"])//9 + , "org.NAME" //9 + , "PERSON.PERSONID" //10 + ]) .from("CONTACT") .join("ORGANISATION", "CONTACT.ORGANISATION_ID = org.ORGANISATIONID", "org") .leftJoin("PERSON", "PERSON.PERSONID = CONTACT.PERSON_ID") @@ -131,6 +133,7 @@ if(idValues == false) for (var i = 0; i < visitFrequencyData.length; i++) { + var isPersonContact = visitFrequencyData[i][10] != "" var dueDate = ""; var lastVisitDate = ""; var today = datetime.date(); @@ -177,7 +180,7 @@ if(idValues == false) "", //USER_NEW.displayValue "", //USER_NEW.value ContactUtils.getFullTitleByContactId(visitFrequencyData[i][1], false), //CONTACT_PERSON_ID.displayValue - visitFrequencyData[i][1], //CONTACT_PERSON_ID.value + isPersonContact ? visitFrequencyData[i][1]: "", //CONTACT_PERSON_ID.value "", //RESPONSIBLE.displayValue "" //RESPONSIBLE.value ];