Automatic generation of a todo4teams message


In this tutorial we would like to introduce you to a possibility to automatically send messages to a specific recipient or a specific group of recipients.
Messages are a special type of communication job in todo4teams, more detailed information can be found in this part of our manual.

Messages can be sent automatically using the "helper.createMessage" method, with various options for parameterization.
In the simplest case, the method call looks like this:

helper.createMessage(Gruppen-ID, Titel, Inhalt, Zielzeit-Minuten, Priortät, Besitzer-ID);

If you also want to attach one or more forms to the message (see example below), use this function:

helper.createMessage(Gruppen-ID, Titel, Inhalt, Zielzeit-Minuten, Priortät, Besitzer-ID, Formulare);

Here is the syntax of the method for creating the message with attached forms, file attachments and other ticket properties:

helper.createMessage(Gruppen-ID, Titel, Inhalt, Zielzeit-Minuten, Priortät, Besitzer-ID, Formulare, Dateianhänge, Eigenschaften);

One possibility would be, for example, to add the method to the start-action of a mailbox.

When a mail arrives in a mailbox, the following script snippet automatically sends a message to all members of group 21 with the title "New message in mailbox", the content "The content can be found here" and a target time of 30 minutes for the reply a priority of 5 stars. The owner of the message would be the user with ID 20.

helper.createMessage(21, "New message in mailbox", "The content can be found here", 30, 4, 20);

More complex workflows can also be mapped using the "helper.createMessage" method. Below is a quick example of a message going to a group that will take care of the calendar orders for the next year. A form is to be automatically attached to this message in which the number of calendars for each customer is to be entered.

A reference to the form is generated in the script (here in the example of form 202) and the form value "Number" is pre-assigned:

var HashMap = Java.type('java.util.HashMap');
var LongType = Java.type('java.lang.Long');
var formsMap = new HashMap();
var form= new HashMap();
form.put("Number", "Please give us the number.");
formsMap.put(new LongType(202), form);

The corresponding form with the ID 202, the one with the above Script is addressed:

Bildschirmfoto vom 2020-10-01 09-40-49.png

This can now be attached automatically with the following script snippet and the message sent:

helper.createMessage(17,  "Calendar order", "Please fill out the form!", 120, 1, 16, formsMap);

The message is sent to all members of group 17 with the title "Calendar order" and the content "Please fill out the form!" as well as a target time for the answer of 120 minutes and a priority of 2 stars. The owner of the message would be the user with ID 16.

Each recipient of the message can now confirm it and fill in form 202 in his response. The user 20 (as the owner / sender of the message) can then conveniently evaluate the list of all responses.

     

Child Pages