Skip to content
Snippets Groups Projects
Commit d164a530 authored by Benjamin Ulrich's avatar Benjamin Ulrich :speech_balloon: Committed by Johannes Goderbauer
Browse files

[Projekt: Entwicklung - Neon][TicketNr.: 1063698][Aufgabe/Aktivität aus Termin erstellen]

parent dcc97063
No related branches found
No related tags found
No related merge requests found
import("system.db");
import("KeywordRegistry_basic");
import("Contact_lib");
import("system.vars");
import("ActivityTask_lib");
import("Context_lib");
import("Sql_lib");
import("system.entities");
var uid = vars.get("$field.UID");
var appointmentLinkConfig = entities.createConfigForLoadingConsumerRows().consumer("AppointmentLinks")
.fields(["OBJECTID", "OBJECTTYPE"]);
var appointmentLinks = entities.getRows(appointmentLinkConfig);
var objectdata = newSelect("OBJECT_TYPE, OBJECT_ROWID")
.from("AB_APPOINTMENTLINK")
.where("AB_APPOINTMENTLINK.APPOINTMENT_ID", "$field.UID")
.arrayRow();
var links = [];
if (objectdata.length > 0)
{
links.push(objectdata);
//filter only for objectTypes that may bet set in Activity (In AppointmentLink_entity there can be linked more objects than in the ActivityLink_entity)
//this needs to be done if links exists, otherwise we can spare this for better performance
if (appointmentLinks.length > 0)
{
var availableActivityObjectTypesSet = ActivityUtils.getLinkableObjectTypes();
var links = [];
appointmentLinks.forEach(function(appointmentLink){
var linkType = appointmentLink["OBJECTTYPE"];
var isLinkableType = availableActivityObjectTypesSet.has(linkType);
if (isLinkableType)
links.push([linkType, appointmentLink["OBJECTID"]]);
});
}
ActivityUtils.createNewActivity(undefined, links, ContextUtils.getCurrentContextId(), vars.get("$field.UID"), vars.get("$field.SUMMARY"), vars.get("$field.DESCRIPTION"), $KeywordRegistry.activityDirection$outgoing());
//pParentContext and pParentId have been set to null because an appoint can not be the predecessor of an activity at the moment
ActivityUtils.createNewActivity(undefined, links, null, null, vars.get("$field.SUMMARY"), vars.get("$field.DESCRIPTION"), $KeywordRegistry.activityDirection$outgoing());
import("system.entities");
import("system.vars");
import("system.util");
import("system.datetime");
......@@ -24,6 +25,31 @@ import("Context_lib");
*/
function ActivityUtils() {}
/**
* Determines object types (=context ids) by loading them from the Context_entity.ActivityLinkable provider.
*
* @return {Set} <br/>Set that contains the context ids as string elements
* @example
* var linkableTypes = ActivityUtils.getLinkableObjectTypes();
* linkableTypes.has("Organisation");//true
* linkableTypes.has("Actvity");//false
*/
ActivityUtils.getLinkableObjectTypes = function()
{
var entityConfig = entities.createConfigForLoadingRows().entity("Context_entity")
.fields(["UID"])//UID contains the technical name
.provider("ActivityLinkable");
var availableActivityObjectTypes = entities.getRows(entityConfig);
var res = new Set();
for (var i = 0, l = availableActivityObjectTypes.length; i < l; i++)
{
if (availableActivityObjectTypes[i]["UID"])
res.add(availableActivityObjectTypes[i]["UID"]);
}
return res;
};
/**
* Create a new activity within the database-scope.
* This funciton will insert a complete new activity into the database.
......
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