Skip to content
Snippets Groups Projects
Commit f98f30a8 authored by Johannes Hörmann's avatar Johannes Hörmann
Browse files

fix copy bulkmail

parent fed3b06a
No related branches found
No related tags found
No related merge requests found
......@@ -50,7 +50,6 @@
<onValueChange>%aditoprj%/entity/BulkMail_entity/entityfields/documenttemplate_id/onValueChange.js</onValueChange>
<onValueChangeTypes>
<element>MASK</element>
<element>PROCESS_SETVALUE</element>
</onValueChangeTypes>
</entityField>
<entityConsumer>
......
......@@ -2,5 +2,13 @@ import("system.vars");
import("system.neon");
import("Bulkmail_lib");
// How the copy works:
// - the Bulkmail-context is called in NEW mode and CopyBulkMailId_param set to the current bulkmail id
// - the valueProcess of field BULKMAILID is used to load the data via loadEntity and sets the fields
// (Note: I also could have done it like in offer / order and provide everything as parameter,
// but I tried if i it is possible to do it with less processes and a central process loading the data.
// - The $field.bindata field is set seperately in it's value process
// - The Recipients are added in onDBInsert of the record container
BulkMailUtils.copy(vars.get("$field.BULKMAILID"));
\ No newline at end of file
......@@ -2,4 +2,4 @@ import("Bulkmail_lib");
import("system.vars");
import("system.result");
result.object(!BulkMailUtils.isStatusSendingOrSent);
\ No newline at end of file
result.object(!BulkMailUtils.isStatusSendingOrSent(vars.get("$field.STATUS")));
\ No newline at end of file
import("system.logging");
import("Sql_lib");
import("DocumentTemplate_lib");
import("system.result");
import("system.vars");
import("system.entities");
import("system.db");
import("system.util");
import("Document_lib");
......@@ -26,7 +28,36 @@ if (template.content)
"", template.content, template.filename, "", "", SqlUtils.getBinariesAlias());
}
var contactIds = JSON.parse(vars.getString("$param.PresetRecipients_param"));
var contactIds = [];
if (vars.get("$param.CopyBulkMailId_param"))
{
logging.log(JSON.stringify(["COPY: ",
"BulkMailRecipient_entity",
"BulkMailRecipients",
["BulkMailId_param", vars.get("$param.CopyBulkMailId_param")],
["#UID"]
], null, "\t"))
var config = entities.createConfigForLoadingRows()
.entity("BulkMailRecipient_entity")
.provider("BulkMailRecipients")
.addParameter("BulkMailId_param", vars.get("$param.CopyBulkMailId_param"))
.fields(["CONTACT_ID"]);
var copiedRecipients = entities.getRows(config);
logging.log(JSON.stringify([copiedRecipients], null, "\t"))
contactIds = copiedRecipients.map(function(pRecipient)
{
return pRecipient["CONTACT_ID"];
});
}
if (vars.getString("$param.PresetRecipients_param"))
contactIds = contactIds.concat(JSON.parse(vars.getString("$param.PresetRecipients_param")));
logging.log(JSON.stringify([contactIds], null, "\t"))
if (contactIds && contactIds.length > 0)
BulkMailUtils.addRecipients(bulkMailId, BulkMailUtils.filterNewRecipients(bulkMailId, contactIds));
\ 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