diff --git a/entity/LetterRecipient_entity/LetterRecipient_entity.aod b/entity/LetterRecipient_entity/LetterRecipient_entity.aod
index fa499a6fcbc90f8ac742026755d0f45a5d105e18..4ee79449c0c3f04cbff56308d31781746af87b9a 100644
--- a/entity/LetterRecipient_entity/LetterRecipient_entity.aod
+++ b/entity/LetterRecipient_entity/LetterRecipient_entity.aod
@@ -135,7 +135,6 @@
         </dbRecordFieldMapping>
         <dbRecordFieldMapping>
           <name>HASCOMMRESTRICTION.value</name>
-          <expression>%aditoprj%/entity/LetterRecipient_entity/recordcontainers/db/recordfieldmappings/hascommrestriction.value/expression.js</expression>
         </dbRecordFieldMapping>
         <dbRecordFieldMapping>
           <name>TARGETCONTEXT.value</name>
diff --git a/entity/SerialLetter_entity/entityfields/downloadletter/onActionProcess.js b/entity/SerialLetter_entity/entityfields/downloadletter/onActionProcess.js
index 11b5418889d70f613b3ffeea95ed7005f67bdc10..567c05b192792aaf4574954ee19486bfb5ce9145 100644
--- a/entity/SerialLetter_entity/entityfields/downloadletter/onActionProcess.js
+++ b/entity/SerialLetter_entity/entityfields/downloadletter/onActionProcess.js
@@ -1,19 +1,20 @@
-import("Binary_lib");
+import("system.vars");
 import("system.util");
-import("DocumentTemplate_lib");
 import("system.neon");
+import("Binary_lib");
+import("Employee_lib");
 import("Bulkmail_lib");
-import("system.vars");
+import("DocumentTemplate_lib");
 import("system.notification");
-import("Employee_lib");
 
 var letterId = vars.get("$field.SERIALLETTERID");
+
 if (vars.get("$field.generated"))
 {
-    var metadata = SingleBinaryUtils.getMetadata("SERIALLETTER", "SERIALLETTERFILE", letterId);
+    var metadata = SingleBinaryUtils.getMetadata("SERIALLETTER", "SERIALLETTERFILE", letterId, null, null, "SERIALLETTER_BUILDED");
     if (metadata)
     {
-        var document = SingleBinaryUtils.get("SERIALLETTER", "SERIALLETTERFILE", letterId);
+        var document = SingleBinaryUtils.get("SERIALLETTER", "SERIALLETTERFILE", letterId, null, "SERIALLETTER_BUILDED");
         neon.download(document, metadata.filename);
     }
 }
\ No newline at end of file
diff --git a/entity/SerialLetter_entity/entityfields/generated/valueProcess.js b/entity/SerialLetter_entity/entityfields/generated/valueProcess.js
index 72d106321d52d6ce96a44bb81b48c8d0b1a08d6b..90cfd48bd3023645465d705e959ad1b2ad38930c 100644
--- a/entity/SerialLetter_entity/entityfields/generated/valueProcess.js
+++ b/entity/SerialLetter_entity/entityfields/generated/valueProcess.js
@@ -3,5 +3,5 @@ import("system.neon");
 import("system.vars");
 import("system.result");
 
-result.string(vars.get("$sys.viewmode") == neon.FRAME_VIEWMODE_DATASET && SingleBinaryUtils.checkExistsOneTime("SERIALLETTER", "SERIALLETTERFILE", vars.get("$field.SERIALLETTERID"))
-    ? "true" : "");
\ No newline at end of file
+result.string(vars.get("$sys.viewmode") == neon.FRAME_VIEWMODE_DATASET && 
+                SingleBinaryUtils.checkExistsOneTime("SERIALLETTER", "SERIALLETTERFILE", vars.get("$field.SERIALLETTERID"), null, "SERIALLETTER_BUILDED") ? "true" : "");
\ No newline at end of file
diff --git a/entity/SerialLetter_entity/recordcontainers/db/onDBInsert.js b/entity/SerialLetter_entity/recordcontainers/db/onDBInsert.js
index 408cbf0666bb3d07a28c4eaacb87d9872a6332f7..683f7df026e987761da1e9e65f961e27f0636324 100644
--- a/entity/SerialLetter_entity/recordcontainers/db/onDBInsert.js
+++ b/entity/SerialLetter_entity/recordcontainers/db/onDBInsert.js
@@ -1,3 +1,4 @@
+import("system.logging");
 import("Workflow_lib");
 import("Binary_lib");
 import("Sql_lib");
@@ -15,7 +16,8 @@ var template = DocumentTemplate.fromUpload(bindata);
 
 if (template.content)
 {
-    SingleBinaryUtils.insert("SERIALLETTER", "SERIALLETTERFILE", letterId, template.content, template.filename, "");
+    logging.log("inside");
+    SingleBinaryUtils.insert("SERIALLETTER", "SERIALLETTERFILE", letterId, template.content, template.filename, "", "SERIALLETTER_BUILDED");
 }
 
 WorkflowSignalSender.inserted();
\ No newline at end of file
diff --git a/entity/SerialLetter_entity/recordcontainers/db/onDBUpdate.js b/entity/SerialLetter_entity/recordcontainers/db/onDBUpdate.js
index 20c7fc0a0ddd70bb3075f0f5c90bd95d19e01233..8e2cd7814cde414b535183b90ac3e3245e2d838a 100644
--- a/entity/SerialLetter_entity/recordcontainers/db/onDBUpdate.js
+++ b/entity/SerialLetter_entity/recordcontainers/db/onDBUpdate.js
@@ -17,7 +17,7 @@ var template = DocumentTemplate.fromUpload(bindata);
 
 if (template.content)
 {
-    SingleBinaryUtils.set("SERIALLETTER", "DOCUMENT", letterId, template.content, template.filename, "");
+    SingleBinaryUtils.set("SERIALLETTER", "SERIALLETTERFILE", letterId, template.content, template.filename, "", undefined, "SERIALLETTER_BUILDED");
 }
 
 WorkflowSignalSender.updated();
\ No newline at end of file
diff --git a/process/Binary_lib/process.js b/process/Binary_lib/process.js
index 64a4248d912b75af1cc439a0229441112876ad7c..42b5c995df062c2a7b73c1debe868ce148ff2d5b 100644
--- a/process/Binary_lib/process.js
+++ b/process/Binary_lib/process.js
@@ -69,23 +69,25 @@ function SingleBinaryUtils() {}
  * @param {String} pAssignmentRowId                         <p>
  *                                                          The row id.<br>
  *                                                          (e.g.: UUID of the record)<br>
- * @param {String} pAlias=SqlUtils.getBinariesAlias()       <p>
+ * @param {String} [pAlias=SqlUtils.getBinariesAlias()]     <p>
  *                                                          The database alias.<br>
- *                                                          (e.g.: _____SYSTEMALIAS)  
+ *                                                          (e.g.: _____SYSTEMALIAS)<br>
+ * @param {String} [pKeyword]                               <p>
+ *                                                          The binary keyword.<br>
+ *                                                          (e.g.: "SERIALLETTER_BUILDED")<br>
  * @throws {Error}                                          <p>
  *                                                          If more than one binary exists.<br>
  *                                                          This shouldn't happen, if this lib is used.<br>
  * @return {String | Boolean}                               <p>
  *                                                          The binary data or false if no data exists.<br>
  */
-SingleBinaryUtils.get = function(pAssignmentTable, pAssignmentName, pAssignmentRowId, pAlias)
+SingleBinaryUtils.get = function(pAssignmentTable, pAssignmentName, pAssignmentRowId, pAlias, pKeyword)
 {
-    if (pAlias == undefined) 
-        pAlias = SqlUtils.getBinariesAlias();
+    pAlias = pAlias || SqlUtils.getBinariesAlias();
     
-    if (this.checkExistsOneTime(pAssignmentTable, pAssignmentName, pAssignmentRowId, pAlias))
+    if (this.checkExistsOneTime(pAssignmentTable, pAssignmentName, pAssignmentRowId, pAlias, pKeyword))
     {
-        var binaryMetadata = db.getBinaryMetadata(pAssignmentTable, pAssignmentName, pAssignmentRowId, false, pAlias)[0];
+        var binaryMetadata = db.getBinaryMetadata(pAssignmentTable, pAssignmentName, pAssignmentRowId, false, pAlias, pKeyword)[0];
         return db.getBinaryContent(binaryMetadata.id, pAlias);
     }
 
@@ -104,11 +106,14 @@ SingleBinaryUtils.get = function(pAssignmentTable, pAssignmentName, pAssignmentR
  * @param {String} pAssignmentRowId                                 <p>
  *                                                                  The row id.<br>
  *                                                                  (e.g.: UUID of the record)<br>
- * @param {Boolean} pIncludePreview=false (optional)                <p>
+ * @param {Boolean} [pIncludePreview=false]                         <p>
  *                                                                  Case if its true, a preview will also be retrieved.<br>
- * @param {String} pAlias=SqlUtils.getBinariesAlias() (optional)    <p>
+ * @param {String} [pAlias=SqlUtils.getBinariesAlias()]             <p>
  *                                                                  The database alias.<br>
  *                                                                  (e.g.: _____SYSTEMALIAS)<br> 
+ * @param {String} [pKeyword]                                       <p>
+ *                                                                  The binary keyword.<br>
+ *                                                                  (e.g.: "SERIALLETTER_BUILDED")<br> 
  * @throws {Error}                                                  <p>
  *                                                                  If more than one binary exists.<br>
  *                                                                  This shouldn't happen, if this lib is used.<br>
@@ -117,14 +122,13 @@ SingleBinaryUtils.get = function(pAssignmentTable, pAssignmentName, pAssignmentR
  *                                                                  filename, edit, keyword, description, size, mimetype) <br>
  *                                                                  or false if no data exists.<br>
  */
-SingleBinaryUtils.getMetadata = function(pAssignmentTable, pAssignmentName, pAssignmentRowId, pIncludePreview, pAlias)
+SingleBinaryUtils.getMetadata = function(pAssignmentTable, pAssignmentName, pAssignmentRowId, pIncludePreview, pAlias, pKeyword)
 {
-    if (pAlias == undefined) 
-        pAlias = SqlUtils.getBinariesAlias();
+    pAlias = pAlias || SqlUtils.getBinariesAlias();
     
-    if (this.checkExistsOneTime(pAssignmentTable, pAssignmentName, pAssignmentRowId, pAlias))
+    if (this.checkExistsOneTime(pAssignmentTable, pAssignmentName, pAssignmentRowId, pAlias, pKeyword))
     {
-        return db.getBinaryMetadata(pAssignmentTable, pAssignmentName, pAssignmentRowId, pIncludePreview || false, pAlias)[0];
+        return db.getBinaryMetadata(pAssignmentTable, pAssignmentName, pAssignmentRowId, pIncludePreview || false, pAlias, pKeyword)[0];
     }
 
     return false;
@@ -142,9 +146,12 @@ SingleBinaryUtils.getMetadata = function(pAssignmentTable, pAssignmentName, pAss
  * @param {String} pAssignmentRowId                                 <p>
  *                                                                  The row id.<br>
  *                                                                  (e.g.: UUID of the record)<br>
- * @param {String} pAlias=SqlUtils.getBinariesAlias() (optional)    <p>
+ * @param {String} [pAlias=SqlUtils.getBinariesAlias()]             <p>
  *                                                                  The database alias.<br>
  *                                                                  (e.g.: _____SYSTEMALIAS)<br>
+ * @param {String} [pKeyword]                                       <p>
+ *                                                                  The binary keyword.<br>
+ *                                                                  (e.g.: "SERIALLETTER_BUILDED")<br>
  * @throws {Error}                                                  <p>
  *                                                                  If more than one binary exists. <br>
  *                                                                  This shouldn't happen, if this lib is used.<br>
@@ -152,12 +159,10 @@ SingleBinaryUtils.getMetadata = function(pAssignmentTable, pAssignmentName, pAss
  *                                                                  Result of the check. If yes, it returns true.<br>
  *                                                                  If it doesn't exist, it returns false.<br>
  */
-SingleBinaryUtils.checkExistsOneTime = function(pAssignmentTable, pAssignmentName, pAssignmentRowId, pAlias)
+SingleBinaryUtils.checkExistsOneTime = function(pAssignmentTable, pAssignmentName, pAssignmentRowId, pAlias, pKeyword)
 {   
-    if (pAlias == undefined) 
-        pAlias = SqlUtils.getBinariesAlias();
-    
-    var countBinary = db.getBinaryCount(pAssignmentTable, pAssignmentName, pAssignmentRowId, pAlias);
+    pAlias = pAlias || SqlUtils.getBinariesAlias();
+    var countBinary = db.getBinaryCount(pAssignmentTable, pAssignmentName, pAssignmentRowId, pAlias, pKeyword || null);
     
     if (countBinary == 0)
     {
@@ -189,11 +194,12 @@ SingleBinaryUtils.checkExistsOneTime = function(pAssignmentTable, pAssignmentNam
  *                                                                  The name of the file.<br>
  * @param {String} pDescription                                     <p>
  *                                                                  The file description.<br>
- * @param {String} pKeyword                                         <p>
- *                                                                  The keyword.<br>
- * @param {String} pAlias=SqlUtils.getBinariesAlias() (optional)    <p>
+ * @param {String} [pAlias=SqlUtils.getBinariesAlias()]             <p>
  *                                                                  The database alias.<br>
  *                                                                  (e.g.: _____SYSTEMALIAS)<br>
+ * @param {String} [pKeyword]                                       <p>
+ *                                                                  The binary keyword.<br>
+ *                                                                  (e.g.: "SERIALLETTER_BUILDED")<br>
  * @throws {Error}                                                  <p>
  *                                                                  If more than one binary exists.<br>
  *                                                                  This shouldn't happen, if this lib is used.<br>
@@ -203,10 +209,9 @@ SingleBinaryUtils.checkExistsOneTime = function(pAssignmentTable, pAssignmentNam
  */
 SingleBinaryUtils.insert = function(pAssignmentTable, pAssignmentName, pAssignmentRowId, pBase64, pFileName, pDescription, pKeyword, pAlias)
 {
-    if (pAlias == undefined) 
-        pAlias = SqlUtils.getBinariesAlias();
+    pAlias = pAlias || SqlUtils.getBinariesAlias();
     
-    if (!this.checkExistsOneTime(pAssignmentTable, pAssignmentName, pAssignmentRowId, pAlias))
+    if (!this.checkExistsOneTime(pAssignmentTable, pAssignmentName, pAssignmentRowId, pAlias, pKeyword))
     {
         return db.insertBinary(pAssignmentTable, pAssignmentName, pAssignmentRowId, "", pBase64, pFileName, (pDescription || ""), pKeyword, pAlias);
     }
@@ -233,7 +238,7 @@ SingleBinaryUtils.insert = function(pAssignmentTable, pAssignmentName, pAssignme
  *                                                                      The name of the file.<br>
  * @param {String} pDescription                                         <p>
  *                                                                      The file description.<br>
- * @param {String} pAlias=SqlUtils.getBinariesAlias() (optional)        <p>
+ * @param {String} [pAlias=SqlUtils.getBinariesAlias()]                 <p>
  *                                                                      The database alias.<br>
  *                                                                      (e.g.: _____SYSTEMALIAS)<br>
  * @throws {Error}                                                      <p>
@@ -266,9 +271,12 @@ SingleBinaryUtils.insertMainDocument = function(pAssignmentTable, pAssignmentNam
  *                                                                  The name of the file.<br>
  * @param {String} pDescription                                     <p>
  *                                                                  The file description.<br> 
- * @param {String} pAlias=SqlUtils.getBinariesAlias() (optional)    <p>
+ * @param {String} [pAlias=SqlUtils.getBinariesAlias()]             <p>
  *                                                                  The database alias.<br>
  *                                                                  (e.g.: _____SYSTEMALIAS)<br> 
+ * @param {String} [pKeyword]                                       <p>
+ *                                                                  The binary keyword.<br>
+ *                                                                  (e.g.: "SERIALLETTER_BUILDED")<br>
  * @throws {Error}                                                  <p>
  *                                                                  If more than one binary exists.<br>
  *                                                                  This shouldn't happen, if this lib is used.<br>
@@ -276,16 +284,16 @@ SingleBinaryUtils.insertMainDocument = function(pAssignmentTable, pAssignmentNam
  *                                                                  True if inserted, false if the binary <br>
  *                                                                  was not found.<br>
  */
-SingleBinaryUtils.update = function(pAssignmentTable, pAssignmentName, pAssignmentRowId, pBase64, pFileName, pDescription, pAlias)
+SingleBinaryUtils.update = function(pAssignmentTable, pAssignmentName, pAssignmentRowId, pBase64, pFileName, pDescription, pAlias, pKeyword)
 {
     if (pAlias == undefined) 
         pAlias = SqlUtils.getBinariesAlias();
     
-    if (this.checkExistsOneTime(pAssignmentTable, pAssignmentName, pAssignmentRowId, pAlias))
+    if (this.checkExistsOneTime(pAssignmentTable, pAssignmentName, pAssignmentRowId, pAlias, pKeyword))
     {
-        var binaryMetadata = db.getBinaryMetadata(pAssignmentTable, pAssignmentName, pAssignmentRowId, false, pAlias)[0];
+        var binaryMetadata = db.getBinaryMetadata(pAssignmentTable, pAssignmentName, pAssignmentRowId, false, pAlias, pKeyword)[0];
         
-        db.updateBinary(binaryMetadata.id, "", pBase64, pFileName, pDescription, "", pAlias);
+        db.updateBinary(binaryMetadata.id, "", pBase64, pFileName, pDescription, pKeyword, pAlias);
         return true;
     }
     
@@ -346,9 +354,12 @@ SingleBinaryUtils.remove = function(pAssignmentTable, pAssignmentName, pAssignme
  *                                                                  The name of the file.<br>
  * @param {String} pDescription                                     <p>
  *                                                                  The file description.<br>
- * @param {String} pAlias=SqlUtils.getBinariesAlias() (optional)    <p>
+ * @param {String} [pAlias=SqlUtils.getBinariesAlias()]             <p>
  *                                                                  The database alias.<br>
- *                                                                  (e.g.: _____SYSTEMALIAS)<br>
+ *                                                                  (e.g.: _____SYSTEMALIAS)<br> 
+ * @param {String} [pKeyword]                                       <p>
+ *                                                                  The binary keyword.<br>
+ *                                                                  (e.g.: "SERIALLETTER_BUILDED")<br>
  * @throws {Error}                                                  <p>
  *                                                                  If more than one binary exists.<br>
  *                                                                  This shouldn't happen, if this lib is used.<br>
@@ -357,12 +368,12 @@ SingleBinaryUtils.remove = function(pAssignmentTable, pAssignmentName, pAssignme
  *                                                                  the binary id if it was inserted, <br>
  *                                                                  false if it failed.<br>
  */
-SingleBinaryUtils.set = function(pAssignmentTable, pAssignmentName, pAssignmentRowId, pBase64, pFileName, pDescription, pAlias)
+SingleBinaryUtils.set = function(pAssignmentTable, pAssignmentName, pAssignmentRowId, pBase64, pFileName, pDescription, pAlias, pKeyword)
 {
     //try to update, if not possible, insert
-    var wasSet = SingleBinaryUtils.update(pAssignmentTable, pAssignmentName, pAssignmentRowId, pBase64, pFileName, pDescription, pAlias)
+    var wasSet = SingleBinaryUtils.update(pAssignmentTable, pAssignmentName, pAssignmentRowId, pBase64, pFileName, pDescription, pAlias, pKeyword);
     if (!wasSet)
-        wasSet = SingleBinaryUtils.insert(pAssignmentTable, pAssignmentName, pAssignmentRowId, pBase64, pFileName, pDescription, "", pAlias);
+        wasSet = SingleBinaryUtils.insert(pAssignmentTable, pAssignmentName, pAssignmentRowId, pBase64, pFileName, pDescription, pKeyword, pAlias);
     
     return wasSet;
 }
diff --git a/process/Bulkmail_lib/process.js b/process/Bulkmail_lib/process.js
index 2b2ccd267253a68b450b2326d25972f8738b8117..9b3c54be55b645f66dcd68b2c4174ffc52e9ccc6 100644
--- a/process/Bulkmail_lib/process.js
+++ b/process/Bulkmail_lib/process.js
@@ -943,36 +943,41 @@ SerialLetterUtils.buildSerialLetterOnServer = function (pSerialLetterId, pRecipi
 SerialLetterUtils.buildSerialLetter = function (pSerialLetterId, pRecipientIds)
 {
     var [templateId, title] = newSelect("DOCUMENTTEMPLATE_ID, TITLE")
-                        .from("SERIALLETTER")
-                        .where("SERIALLETTER.SERIALLETTERID", pSerialLetterId)
-                        .arrayRow(true);
+                                .from("SERIALLETTER")
+                                .where("SERIALLETTER.SERIALLETTERID", pSerialLetterId)
+                                .arrayRow(true);
 
     var template = SerialLetterUtils.getSerialLetterTemplate(pSerialLetterId, templateId);
     var contactIdsSelect = newSelect("CONTACT_ID")
-                        .from("LETTERRECIPIENT")
-                        .join("CONTACT", newWhere("LETTERRECIPIENT.CONTACT_ID = CONTACT.CONTACTID"))
-                        .where("LETTERRECIPIENT.SERIALLETTER_ID", pSerialLetterId)
-                        .andIfSet(new CommunicationSettingsCondition()
-                            .postalAddress("LETTERRECIPIENT.ADDRESS_ID")
-                            .rejected()
-                            .existNoSettings()
-                            .buildCondition());
+                            .from("LETTERRECIPIENT")
+                            .join("CONTACT", newWhere("LETTERRECIPIENT.CONTACT_ID = CONTACT.CONTACTID"))
+                            .where("LETTERRECIPIENT.SERIALLETTER_ID", pSerialLetterId)
+                            .andIfSet(new CommunicationSettingsCondition()
+                                .address("CONTACT.ADDRESS_ID")
+                                .rejected()
+                                .existNoSettings()
+                                .buildCondition());
 
     if (pRecipientIds && pRecipientIds.length > 0)
+    {    
         contactIdsSelect.and("LETTERRECIPIENT.LETTERRECIPIENTID", pRecipientIds, SqlBuilder.IN());
+    }
 
     var contactIds = contactIdsSelect.table();
-    if(template != null){
-    return {
-        content : template.getSerialLetterByContactIds(contactIds),
-        filename : template.filename,
-        title : title
-    };}
-    else{
+    
+    if(template != null)
+    {
+        return {
+            content : template.getSerialLetterByContactIds(contactIds),
+            filename : template.filename,
+            title : title
+        };
+    }
+    else
+    {
         return{
             title : title
-}
-
+        }
     }
 }
 
diff --git a/process/DocumentTemplate_lib/process.js b/process/DocumentTemplate_lib/process.js
index 9fdd37832b66679a34fb7a4b7304e22a7b959ab1..74f19214f10db8259cc8e314878a63ba5b2b6fec 100644
--- a/process/DocumentTemplate_lib/process.js
+++ b/process/DocumentTemplate_lib/process.js
@@ -306,12 +306,16 @@ DocumentTemplate.loadTemplate = function (pAssignmentRowId, pAssignmentTable, pR
 {   
     var alias = SqlUtils.getBinariesAlias();
     if (!pAssignmentTable)
+    {    
         pAssignmentTable = "DOCUMENTTEMPLATE";
+    }
     
     // if the templateId is accessable, use it, to enable the templateto load attachments
     var templateId;
     if (pAssignmentTable == "DOCUMENTTEMPLATE")
-        templateId = pAssignmentRowId;
+    {
+        templateId = pAssignmentRowId;    
+    }
     
     if (templateId)
     {
@@ -319,17 +323,21 @@ DocumentTemplate.loadTemplate = function (pAssignmentRowId, pAssignmentTable, pR
         if (template == null)
         {
             if(vars.getString("$sys.isserver") == "true")
+            {
                 throw new Error("loadTemplate: File from this template could not be found anymore. "
-                                + "Please go to the template and upload a new file. TemplateID: '" + templateId + "'")
+                                + "Please go to the template and upload a new file. TemplateID: '" + templateId + "'");    
+            }
             else
+            {    
                 question.showMessage(translate.text("File from this template could not be found anymore. "
                                 + "Please go to the template and upload a new file."), question.ERROR, translate.text("Error"));
+            }
             
             return null;
         }
     }
     var templateDocument;
-    if(pAssignmentTable == "SERIALLETTER")
+    if(pAssignmentTable == "SERIALLETTER" && db.getBinaryCount(pAssignmentTable, "SERIALLETTERFILE", pAssignmentRowId, alias, null) > 0)
     {
         templateDocument = db.getBinaryMetadata(pAssignmentTable, "SERIALLETTERFILE", pAssignmentRowId, false, alias, null);
     }
@@ -338,14 +346,18 @@ DocumentTemplate.loadTemplate = function (pAssignmentRowId, pAssignmentTable, pR
         templateDocument = db.getBinaryMetadata(pAssignmentTable, "DOCUMENT", pAssignmentRowId, false, alias, null);
     }
     if (!templateDocument[0])
+    {    
         return new DocumentTemplate(undefined, undefined, undefined, undefined, templateId);
+    }
     var binaryId = templateDocument[0][db.BINARY_ID];
     var filename = templateDocument[0][db.BINARY_FILENAME];
     var mimeType = templateDocument[0][db.BINARY_MIMETYPE];
     var type = DocumentTemplate.types.fromBinaryMetadata(templateDocument[0]);
     
     if (pResolveSubtemplates == undefined)
+    {    
         pResolveSubtemplates = true;
+    }
     
     return new DocumentTemplate(db.getBinaryContent(binaryId, alias), type, filename, pResolveSubtemplates, templateId, mimeType);
 }
@@ -542,9 +554,9 @@ DocumentTemplate.prototype.getSerialLetterByContactIds = function (pContactIds,
         {
             return replacements[contactId];
         });
+        
         return this._getReplacedODT(replaceArray, pTableData);
     }
-    
     question.showMessage(DocumentTemplate.getSerialLetterODTOnlyMessage(), question.INFORMATION, translate.text("Action not supported"))
     return null;
 }
@@ -714,24 +726,28 @@ DocumentTemplate.prototype.getReplacementsByContactIds = function (pContactIds,
 DocumentTemplate.prototype._getReplacedODT = function (pReplacements, pTableData)
 {
     var filename =  this.filename;
-    if (!filename)
-        filename = "dummyname.odt";
+    var replacedFileData = null;
     
-    var that = this;
+    if (!filename)
+    {
+        filename = "Replaced-Document-Template.odt";    
+    }
     
     //save the file on the server so it can be unzipped via pack.getFromZip
-    var serverFilePath = vars.get("$sys.servertemp") + "/clientid_" + (vars.exists("$sys.clientid") ? vars.get("$sys.clientid") : 0)
-        + "/" + util.getNewUUID() + "/" + filename.replace(/\\/g, "/");
+    var tmpFolder = vars.get("$sys.servertemp");
+    var clientId = vars.exists("$sys.clientid") ? vars.get("$sys.clientid") : 0;
+    var serverFilePath = tmpFolder + "/clientid_" + clientId + "/" + util.getNewUUID() + "/" + filename.replace(/\\/g, "/");
     
     fileIO.storeData(serverFilePath, this.content, util.DATA_BINARY, false);
-    var replacedFileData = null;
+    
     try 
     {
-        if (!_replaceODTFile(pReplacements, serverFilePath, pTableData))
+        if (!_replaceODTFile(pReplacements, serverFilePath, pTableData, this))
+        {    
             return null;
+        }
 
-        replacedFileData = fileIO.getData(serverFilePath, util.DATA_BINARY);
-        
+        replacedFileData = fileIO.getData(serverFilePath, util.DATA_BINARY);    
     }
     finally 
     {
@@ -744,28 +760,42 @@ DocumentTemplate.prototype._getReplacedODT = function (pReplacements, pTableData
     * replaces placeholders in a odt file
     *
     * @param {Object} pReplacements replacement object
-    * @param {String} pODTFileName filename of the odt
+    * @param {String} pODTFileName filename of the odt  
     * @param {Array} pTableData
+    * @param {Array} pCurrentTemplate the Object of the DocumentTemplate
     * 
     * @return {Boolean}
     */
-    function _replaceODTFile (pReplacements, pODTFileName, pTableData)
+    function _replaceODTFile (pReplacements, pODTFileName, pTableData, pCurrentTemplate)
     {
+        var tablePlaceholders = [];
         var senderRelId = EmployeeUtils.getCurrentContactId();
+        
         if (senderRelId == null)
+        {    
             return false;
+        }
+        
         if (!Array.isArray(pReplacements))
+        {    
             pReplacements = [pReplacements];
+        }
+        
         if (!pTableData)
+        {    
             pTableData = [];
-        var tablePlaceholders = [];
+        }
+        
         if (pTableData.length > 0)
         {
             //pTableData[0] = first document
             tablePlaceholders = pTableData[0].map(function (tblData)
             {
                 if (tblData && tblData.length > 0)
+                {    
                     return new Set(Object.keys(tblData[0])); //tblData[0] = first row
+                }
+                
                 return new Set();
             });
         }
@@ -774,6 +804,7 @@ DocumentTemplate.prototype._getReplacedODT = function (pReplacements, pTableData
         {
             //replace placeholders in content.xml
             var contentXml = util.decodeBase64String(pack.getFromZip(pODTFileName, "content.xml"));
+            
             var bodybegin = contentXml.indexOf("<office:body>");
             var bodyend =  contentXml.indexOf("</office:body>") + 14;
             
@@ -794,19 +825,20 @@ DocumentTemplate.prototype._getReplacedODT = function (pReplacements, pTableData
                 for (let placeholder in replacements)
                 {
                     currentBody = StringUtils.replaceAll(currentBody, placeholder, 
-                        replacements[placeholder].replace(/\n/ig, "<text:line-break/>").replace(/&/ig, "&amp;"), "ig");
+                                        replacements[placeholder].replace(/\n/ig, "<text:line-break/>").replace(/&/ig, "&amp;"), "ig");
                 }
                 
-                
-                let tables = pTableData[i] || [];
-                let tableEnd = 0;
+                var tableEnd = 0;
+                var tables = pTableData[i] || [];
                 //for (let tblIndex = 0; tblIndex < tables.length; tblIndex++) //iterate over all tables in the document
                 if (tables.length > 0)
                 {
-                    let hasMoreTables = currentBody.includes("</table:table>");
-                    for (let tblI = 0; tblI < 10 && hasMoreTables; tblI++)
+                    var hasMoreTables = currentBody.includes("</table:table>");
+                    
+                    for (var tblI = 0; tblI < 10 && hasMoreTables; tblI++)
                     {
                         tableEnd = currentBody.indexOf("</table:table>", tableEnd);
+                        
                         if (tableEnd !== -1) //stop if there is no table
                         {
                             tableEnd += 14;
@@ -833,7 +865,7 @@ DocumentTemplate.prototype._getReplacedODT = function (pReplacements, pTableData
                                 for (let rowIndex = 0; rowIndex < tableData.length; rowIndex++)
                                 {
                                     let tableRowData = tableData[rowIndex];
-                                    let replacedRow = that._replaceText(tableRow, tableRowData);
+                                    let replacedRow = pCurrentTemplate._replaceText(tableRow, tableRowData);
                                     currentBody += replacedRow;
                                     tableEnd += replacedRow.length;
                                 }
@@ -841,7 +873,9 @@ DocumentTemplate.prototype._getReplacedODT = function (pReplacements, pTableData
                             }
                         }
                         else
+                        {    
                             hasMoreTables = false;
+                        }
                     }
                 }
                 fullBody += currentBody;
diff --git a/process/buildSerialLetter_serverProcess/process.js b/process/buildSerialLetter_serverProcess/process.js
index 7be5de72cd71f6c4dee9d1fab003af0582d4afcd..0ade536ba455e86c5396b756f2234e018b64aafe 100644
--- a/process/buildSerialLetter_serverProcess/process.js
+++ b/process/buildSerialLetter_serverProcess/process.js
@@ -17,19 +17,19 @@ var document = SerialLetterUtils.buildSerialLetter(letterId, recipientIds)
 
 var filename = document.title + "." + DocumentUtil.getFileExtensionFromUpload(document.filename);
 
-SingleBinaryUtils.set("SERIALLETTER", "SERIALLETTERFILE", letterId, document.content, filename, "");
+SingleBinaryUtils.set("SERIALLETTER", "SERIALLETTERFILE", letterId, document.content, filename, "", undefined, "SERIALLETTER_BUILDED");
 
 var message = translate.text("Download ready");
 var description = translate.withArguments("Serial letter \"%0\" can now be downloaded", [document.title]);
 
 var notificationConfig = notification.createConfig()
-.initialState(notification.STATE_UNSEEN)
-.forcedPriority(notification.PRIO_NORMAL)
-    .linkInfo(text.encodeMS(["SerialLetter", letterId]))
-    .daysToLive(2)
-    .addUserWithId(user)
-    .notificationType("DownloadReady")
-    .caption(message)
-    .description(description);
+                                        .initialState(notification.STATE_UNSEEN)
+                                        .forcedPriority(notification.PRIO_NORMAL)
+                                        .linkInfo(text.encodeMS(["SerialLetter", letterId]))
+                                        .daysToLive(2)
+                                        .addUserWithId(user)
+                                        .notificationType("DownloadReady")
+                                        .caption(message)
+                                        .description(description);
     
 notification.addNotificationWith(notificationConfig);
\ No newline at end of file