Tables in Forms


Tables in form allow to work with any number of data entries in a visual representation.

Let's assume you need to list the users of a specific workgroup in a form. Create a new  in todo4teams and add a new form widget of type 'Table':

image-20241210143028-1.png

Edit the new widget, select the tab 'Table' and add two columns:

image-20241210143149-2.png

Save the new form.

Now edit the 'Activate Action' script to fill the table with a list of user when the form is added to a ticket:

var StringArray = Java.type("java.lang.String[]");
var userArray = helper.getUsers();

// prepare table data:
var userMap = new java.util.HashMap();
for (var i = 0; i < userArray.length; ++i) {
   var values = new StringArray(2);
   var user = userArray[i];
   var key = user.getLastname() + "," + user.getFirstname();
    values[0] = key;
    values[1] = user.getEmail();
    userMap.put(key, values);
}    
// set the table data to the visual representation:
helper.setFormValue(form.getMetaName(), "MyTable", users);

This will show the list of users in your form like this:

image-20241210145557-3.png