Skip to content
Snippets Groups Projects
Commit e502aaae authored by Johannes Goderbauer's avatar Johannes Goderbauer
Browse files

Merge remote-tracking branch 'origin/2020.0.2' into 2020.1.0

parents 3888c69a 1cbb0f6d
No related branches found
No related tags found
No related merge requests found
import("system.vars");
import("system.neon");
import("system.result");
if (vars.get("$field.contentPreview"))
result.string(neon.COMPONENTSTATE_READONLY)
\ No newline at end of file
import("Workflow_lib"); import("Workflow_lib");
import("Binary_lib"); import("Binary_lib");
import("Sql_lib"); import("Sql_lib");
import("DocumentTemplate_lib"); import("DocumentTemplate_lib");
import("system.result"); import("system.result");
import("system.vars"); import("system.vars");
import("system.entities"); import("system.entities");
import("system.db"); import("system.db");
import("system.util"); import("system.util");
import("Document_lib"); import("Document_lib");
import("Bulkmail_lib"); import("Bulkmail_lib");
if (vars.get("$field.templateType") != DocumentTemplate.types.EML) if (vars.get("$field.templateType") != DocumentTemplate.types.EML)
var content = vars.get("$field.content"); var content = vars.get("$field.content");
var bindata = vars.get("$field.bindata"); var bindata = vars.get("$field.bindata");
var rowdata = vars.get("$local.rowdata"); var rowdata = vars.get("$local.rowdata");
var bulkMailId = rowdata["BULKMAIL.BULKMAILID"]; var bulkMailId = rowdata["BULKMAIL.BULKMAILID"];
var templateId = rowdata["BULKMAIL.DOCUMENTTEMPLATE_ID"]; var templateId = rowdata["BULKMAIL.DOCUMENTTEMPLATE_ID"];
var bulkMailName = rowdata["BULKMAIL.NAME"]; var bulkMailName = rowdata["BULKMAIL.NAME"];
var template = DocumentTemplate.getSelectedTemplate(templateId, new FileUpload(bindata), content, DocumentTemplate.types.HTML); var template = DocumentTemplate.getSelectedTemplate(templateId, new FileUpload(bindata), content, DocumentTemplate.types.HTML);
if (template && template.content && BulkMailUtils.isValidTemplateType(template.type)) if (template && template.content && BulkMailUtils.isValidTemplateType(template.type))
{ {
if (!template.filename) if (!template.filename)
template.filename = bulkMailName + ".html"; template.filename = bulkMailName + ".html";
SingleBinaryUtils.insert("BULKMAIL", "DOCUMENT", bulkMailId, template.content, template.filename); SingleBinaryUtils.insert("BULKMAIL", "DOCUMENT", bulkMailId, template.content, template.filename);
} }
var contactIds = []; var contactIds = [];
if (vars.get("$param.CopyBulkMailId_param")) if (vars.get("$param.CopyBulkMailId_param"))
{ {
var config = entities.createConfigForLoadingRows() var config = entities.createConfigForLoadingRows()
.entity("BulkMailRecipient_entity") .entity("BulkMailRecipient_entity")
.provider("BulkMailRecipients") .provider("BulkMailRecipients")
.addParameter("BulkMailId_param", vars.get("$param.CopyBulkMailId_param")) .addParameter("BulkMailId_param", vars.get("$param.CopyBulkMailId_param"))
.fields(["CONTACT_ID"]); .fields(["CONTACT_ID"]);
var copiedRecipients = entities.getRows(config); var copiedRecipients = entities.getRows(config);
contactIds = copiedRecipients.map(function(pRecipient) contactIds = copiedRecipients.map(function(pRecipient)
{ {
return pRecipient["CONTACT_ID"]; return pRecipient["CONTACT_ID"];
}); });
} }
if (vars.getString("$param.PresetRecipients_param")) if (vars.getString("$param.PresetRecipients_param"))
contactIds = contactIds.concat(JSON.parse(vars.getString("$param.PresetRecipients_param"))); contactIds = contactIds.concat(JSON.parse(vars.getString("$param.PresetRecipients_param")));
if (contactIds && contactIds.length > 0) if (contactIds && contactIds.length > 0)
BulkMailUtils.addRecipients(bulkMailId, BulkMailUtils.filterNewRecipients(bulkMailId, contactIds)); BulkMailUtils.addRecipients(bulkMailId, BulkMailUtils.filterNewRecipients(bulkMailId, contactIds));
WorkflowSignalSender.inserted(); WorkflowSignalSender.inserted();
\ No newline at end of file
import("Workflow_lib"); import("Workflow_lib");
import("system.util"); import("system.util");
import("Binary_lib"); import("Binary_lib");
import("system.neon"); import("system.neon");
import("Sql_lib"); import("Sql_lib");
import("DocumentTemplate_lib"); import("DocumentTemplate_lib");
import("system.result"); import("system.result");
import("system.vars"); import("system.vars");
import("system.db"); import("system.db");
import("Document_lib"); import("Document_lib");
import("Bulkmail_lib"); import("Bulkmail_lib");
// eml is not editable // eml is not editable
if (vars.get("$field.templateType") != DocumentTemplate.types.EML) if (vars.get("$field.templateType") != DocumentTemplate.types.EML)
var content = vars.get("$field.content"); var content = vars.get("$field.content");
var bindata = vars.get("$field.bindata"); var bindata = vars.get("$field.bindata");
var rowdata = vars.get("$local.rowdata"); var rowdata = vars.get("$local.rowdata");
var bulkMailId = rowdata["BULKMAIL.BULKMAILID"]; var bulkMailId = rowdata["BULKMAIL.BULKMAILID"];
var templateId = rowdata["BULKMAIL.DOCUMENTTEMPLATE_ID"]; var templateId = rowdata["BULKMAIL.DOCUMENTTEMPLATE_ID"];
var bulkMailName = rowdata["BULKMAIL.NAME"]; var bulkMailName = rowdata["BULKMAIL.NAME"];
var template = BulkMailUtils.getBulkMailTemplate(bulkMailId, templateId, false, false, new FileUpload(bindata)); var template = BulkMailUtils.getBulkMailTemplate(bulkMailId, templateId, false, false, new FileUpload(bindata));
if (content) if (content)
template.content = util.encodeBase64String(content); template.content = util.encodeBase64String(content);
if (template && template.content && BulkMailUtils.isValidTemplateType(template.type)) if (template && template.content && BulkMailUtils.isValidTemplateType(template.type))
{ {
if (!template.filename) if (!template.filename)
template.filename = bulkMailName + ".html"; template.filename = bulkMailName + ".html";
SingleBinaryUtils.set("BULKMAIL", "DOCUMENT", vars.get("$local.uid"), template.content, template.filename); SingleBinaryUtils.set("BULKMAIL", "DOCUMENT", vars.get("$local.uid"), template.content, template.filename);
neon.refresh(["$field.content"]); neon.refresh(["$field.content"]);
} }
WorkflowSignalSender.updated(); WorkflowSignalSender.updated();
\ No newline at end of file
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