From 3bb7ed610809abb373e9d134edeffab3eb34ff6f Mon Sep 17 00:00:00 2001 From: "j.goderbauer" <j.goderbauer@jgoderbauer2.aditosoftware.local> Date: Thu, 12 Dec 2019 14:15:12 +0100 Subject: [PATCH] =?UTF-8?q?[Projekt:=20Entwicklung=20-=20Neon][TicketNr.:?= =?UTF-8?q?=201046355][Daten=C3=BCbernehmen=20bei=20Anlage=20neue=20Aktivi?= =?UTF-8?q?t=C3=A4t=20aus=20Aufgabe]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../newactivity/onActionProcess.js | 4 +- process/ActivityTask_lib/process.js | 119 ++++++++++++++++-- 2 files changed, 112 insertions(+), 11 deletions(-) diff --git a/entity/Task_entity/entityfields/newactivity/onActionProcess.js b/entity/Task_entity/entityfields/newactivity/onActionProcess.js index 08d17b66f9..2a5fd911e8 100644 --- a/entity/Task_entity/entityfields/newactivity/onActionProcess.js +++ b/entity/Task_entity/entityfields/newactivity/onActionProcess.js @@ -2,4 +2,6 @@ import("system.vars"); import("ActivityTask_lib"); import("Context_lib"); -ActivityUtils.createNewActivity(undefined, undefined, ContextUtils.getCurrentContextId(), vars.get("$field.TASKID")); \ No newline at end of file +var subject = vars.get("$field.SUBJECT") +var infoText = vars.get("$field.DESCRIPTION"); +ActivityUtils.createNewActivity(undefined, null, ContextUtils.getCurrentContextId(), vars.get("$field.TASKID"), subject, infoText); \ No newline at end of file diff --git a/process/ActivityTask_lib/process.js b/process/ActivityTask_lib/process.js index 1f427eaa2d..554883a0df 100644 --- a/process/ActivityTask_lib/process.js +++ b/process/ActivityTask_lib/process.js @@ -132,10 +132,49 @@ ActivityUtils.insertDocuments = function (pActivityId, pDocuments) else SingleBinaryUtils.insert("ACTIVITY", "DOCUMENT", pActivityId, b64Content, filename); }); -} +}; + /** - * Create a new activity + * Creates a new Activity, this will _not_ insert a new Activity into the database but will open the Activity context in "new" mode and + * presets several fields instead + * + * @param {String} [pRowId] rowid of an record that is linked automatically, as object the current context is used, so this needs to be an ID of + * the current context. Useful whenever you create an Activity from another Object (e.g. an Organisation) and that + * other object shall be linked automatically. There will be no check performed if your given context and id are possible + * values in the ActivityLinks. Specifing nothing (e.g. null) will result in not automatically linking your current + * context + * @param {Array} [pAdditionalLinks] Links that shall be added but are not from an "your curren context view"(see pRowId-param). pAdditionalLinks is a + * two dimensional array where each elemt in the array is in the form of [objectType, objectRowId] + * @param {String} [pParentContext] name of a context that shall be specified as a parent record. The relation between child an parent is: + * 1 parent : n childs; only a fre Contexts are possible parents, e.g.: + * a Task may have other Tasks or Activities as children. + * The pParentContext and pParentId both need to bet set, otherwise no parent will be set + * @param {String} [pParentId] id of record (that is of the given type in pParentContext) which shall be specified as a parent record; see + * pParentContext param + * @param {String} [pSubject] subject text which is set as preset in the Activity + * @param {String} [pInfo] description text which is set as preset in the Activity + * @param {String} [pDirection] direction key (keyword keyid) of the direction which is set as preset in the Activity; consider using $KeywordRegistry + * @param {Object} [pDocuments] 2D array where each element is an array of: + * <ul> + * <li>document-name</li> + * <li>document-content(base64-string)</li> + * <li>true/false if it's mainDocument or not</li> + * </ul> + * for example: + * <pre>[["number.txt", "MDExOCA5OTkgODgxIDk5OSAxMTkgNzI1IDM", true]]</pre> + * @static + * @example + * var content; //will be filled with letter-file as base64 encoded string + * ..... + * var links = []; + * if (contactId) + * { + * var context = ContactUtils.getContextByContactId(contactId); + * links.push([context, contactId]); + * } + * ActivityUtils.createNewActivity(vars.get("$sys.uid"), links, null, null, translate.text("Letter"), translate.text("Outgoing letter was sent."), + * $KeywordRegistry.activityDirection$outgoing(), [["Letter.docx", content, false]]); */ ActivityUtils.createNewActivity = function(pRowId, pAdditionalLinks, pParentContext, pParentId, pSubject, pInfo, pDirection, pDocuments) { @@ -150,7 +189,7 @@ ActivityUtils.createNewActivity = function(pRowId, pAdditionalLinks, pParentCont params["Direction_param"] = pDirection; _ActivityTaskUtils._createNew("Activity", pRowId, pAdditionalLinks, pParentContext, pParentId, params) -} +}; /* * Gets the date of the last activity @@ -233,10 +272,50 @@ ActivityUtils.insertLink = function (pActivityId, pObjectType, pRowId) * @class */ function TaskUtils () {} - /** - * Create a new task + * Creates a new Task, this will _not_ insert a new Task into the database but will open the Task context in "new" mode and + * preset several fields instead + * + * @param {String} [pRowId] rowid of an record that is linked automatically, as object the current context is used, so this needs to be an ID of + * the current context. Useful whenever you create an Task from another Object (e.g. an Organisation) and that + * other object shall be linked automatically. There will be no check performed if your given context and id are possible + * values in the TaskLinks. Specifing nothing (e.g. null) will result in not automatically linking your current + * context + * @param {Array} [pAdditionalLinks] Links that shall be added but are not from an "your curren context view"(see pRowId-param). pAdditionalLinks is a + * two dimensional array where each elemt in the array is in the form of [objectType, objectRowId] + * @param {String} [pParentContext] name of a context that shall be specified as a parent record. The relation between child an parent is: + * 1 parent : n childs; only a fre Contexts are possible parents, e.g.: + * a Task may have other Tasks or Activities as children. + * The pParentContext and pParentId both need to bet set, otherwise no parent will be set + * @param {String} [pParentId] id of record (that is of the given type in pParentContext) which shall be specified as a parent record; see + * pParentContext param + * @param {Object} [pParams] additional params that are bypassed to the Task-context as key-value pairs. If you set a param that is + * populated within another function parameter (e.g. the parent-parameters) the value of pParams will be discarded and the + * value of the "other function parameter" (e.g. the parent-parameter) will be used + * @param {Object} [pDocuments] 2D array where each element is an array of: + * <ul> + * <li>document-name</li> + * <li>document-content(base64-string)</li> + * <li>true/false if it's mainDocument or not</li> + * </ul> + * for example: + * <pre>[["number.txt", "MDExOCA5OTkgODgxIDk5OSAxMTkgNzI1IDM", true]]</pre> + * @static + * @example + * ..... + * var links = []; + * if (contactId) + * { + * links.push([ContactUtils.getContextByContactId(contactId), contactId]); + * } + * + * if (vars.get("$field.SALESPROJECT_ID")) + * { + * links.push(["Salesproject", vars.get("$field.SALESPROJECT_ID")]); + * } + * + * TaskUtils.createNewTask(vars.get("$field.OFFERID"), links, null, null, null, [["Offer.pdf", pdfContent, false]]); */ TaskUtils.createNewTask = function(pRowId, pAdditionalLinks, pParentContext, pParentId, pParams, pDocuments) { @@ -295,14 +374,36 @@ TaskUtils.getOpenTaskCount = function(pRowId, pObjectType) * Do not create an instance of this! * * @ignore + * @private * @class */ function _ActivityTaskUtils() {} - /** - * Create a new task + * Helper function which creates a new activity/task-like objects like Activity, Task or SupportTicket. + * This will _not_ insert a new record into the database but will open the corresponding context in "new" mode and presets several fields instead + * + * @param {String} pContext Name of the Context that shall be opened ("Task", "Activity", etc.) + * @param {String} [pRowId] rowid of an record that is linked automatically, as object the current context is used, so this needs to be an ID of + * the current context. Useful whenever you create an Activity/Task from another Object (e.g. an Organisation) and that + * other object shall be linked automatically. There will be no check performed if your given context and id are possible + * values in ActivityLinks/TaskLinks. Specifing nothing (e.g. null) will result in not automatically linking your current + * context + * @param {Array} [pAdditionalLinks] Links that shall be added but are not from an "your curren context view"(see pRowId-param). pAdditionalLinks is a + * two dimensional array where each elemt in the array is in the form of [objectType, objectRowId] + * @param {String} [pParentContext] name of a context that shall be specified as a parent record. The relation between child an parent is: + * 1 parent : n childs; only a fre Contexts are possible parents, e.g.: + * a Task may have other Tasks or Activities as children. + * The pParentContext and pParentId both need to bet set, otherwise no parent will be set + * Links of parent will be added automatically used as preset + * @param {String} [pParentId] id of record (that is of the given type in pParentContext) which shall be specified as a parent record; see + * pParentContext param + * @param {Object} [pParams] additional params that are bypassed to the context that is opened as key-value pairs. If you set a param that is + * populated within another function parameter (e.g. the parent-parameters) the value of pParams will be discarded and the + * value of the "other function parameter" (e.g. the parent-parameter) will be used + * * @ignore + * @private */ _ActivityTaskUtils._createNew = function(pContext, pRowId, pAdditionalLinks, pParentContext, pParentId, pParams) { @@ -324,14 +425,12 @@ _ActivityTaskUtils._createNew = function(pContext, pRowId, pAdditionalLinks, pPa if (pParentContext && pParentId) { - - params["ParentContext_param"] = pParentContext; params["ParentId_param"] = pParentId; } neon.openContext(pContext, null, null, neon.OPERATINGSTATE_NEW, params); -} +}; /** * add the links to the link-table in new mode -- GitLab