diff --git a/entity/BulkMail_entity/BulkMail_entity.aod b/entity/BulkMail_entity/BulkMail_entity.aod index 5d149ff585210932629400a2fa4b26df179b2cd1..74c3e84fb824e7dc5aed402646e584b712db7510 100644 --- a/entity/BulkMail_entity/BulkMail_entity.aod +++ b/entity/BulkMail_entity/BulkMail_entity.aod @@ -180,6 +180,12 @@ </entityParameter> </children> </entityConsumer> + <entityActionField> + <name>testMail</name> + <title>Test email</title> + <onActionProcess>%aditoprj%/entity/BulkMail_entity/entityfields/testmail/onActionProcess.js</onActionProcess> + <iconId>VAADIN:CLIPBOARD_CHECK</iconId> + </entityActionField> </entityFields> <recordContainers> <dbRecordContainer> diff --git a/entity/BulkMail_entity/entityfields/testmail/onActionProcess.js b/entity/BulkMail_entity/entityfields/testmail/onActionProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..9dcf990316b9b824b8377fc6f18a362be936f684 --- /dev/null +++ b/entity/BulkMail_entity/entityfields/testmail/onActionProcess.js @@ -0,0 +1,4 @@ +import("system.vars"); +import("Bulkmail_lib"); + +BulkMailUtils.sendBulkMailOnServer(vars.get("$field.BULKMAILID")); \ No newline at end of file diff --git a/process/Bulkmail_lib/process.js b/process/Bulkmail_lib/process.js index f262b0fc0ca14ccf163379f82aeb043945bbb8af..d143652488115d6ebd2f2bc51e718b0ff6b75721 100644 --- a/process/Bulkmail_lib/process.js +++ b/process/Bulkmail_lib/process.js @@ -22,16 +22,18 @@ function BulkMailUtils () {} * Executes a process to send bulk mails on the server and creates a notification when finished. * * @param {String} pBulkMailId id of the bulk mail + * @param {Array} [pRecipients=bulkMailRecipients] overwrite the recipients (e.g. for testing) * @param {String} [pUser=currentUser] User that will get the notification, if null (not undefined!), no notification * will be created. */ -BulkMailUtils.sendBulkMailOnServer = function (pBulkMailId, pUser) +BulkMailUtils.sendBulkMailOnServer = function (pBulkMailId, pRecipients, pUser) { if (pUser === undefined) pUser = EmployeeUtils.getCurrentUserId(); process.execute("sendBulkMail_serverProcess", { bulkMailId : pBulkMailId, + recipients : JSON.stringify(pRecipients), user : pUser || "" } ); @@ -42,10 +44,11 @@ BulkMailUtils.sendBulkMailOnServer = function (pBulkMailId, pUser) * can take some time to execute, use BulkMailUtils.sendBulkMailOnServer instead. * * @param {String} pBulkMailId id of the bulk mail + * @param {Array} [pRecipients=bulkMailRecipients] overwrite the recipients (e.g. for testing) * * @return {Object} count of sucessful and failed mails */ -BulkMailUtils.sendBulkMail = function (pBulkMailId) +BulkMailUtils.sendBulkMail = function (pBulkMailId, pRecipients) { var [templateId, subject, emailSender] = db.array(db.ROW, SqlCondition.begin() .andPrepare("BULKMAIL.BULKMAILID", pBulkMailId) diff --git a/process/sendBulkMail_serverProcess/process.js b/process/sendBulkMail_serverProcess/process.js index 68c0371b37a3721cd13e0aef3113a8e170034ecd..89c76bc2898eecb6a7e6772566e775a8e3eed78c 100644 --- a/process/sendBulkMail_serverProcess/process.js +++ b/process/sendBulkMail_serverProcess/process.js @@ -10,7 +10,8 @@ import("system.notification"); var startTime = datetime.date(); var bulkMailId = vars.get("$local.bulkMailId"); var user = vars.get("$local.user"); -var res = BulkMailUtils.sendBulkMail(bulkMailId); +var recipients = JSON.parse(vars.get("$local.recipients")); +var res = BulkMailUtils.sendBulkMail(bulkMailId, recipients); if (user) {