Repeatable Sections

From SMTX Wiki
Jump to navigation Jump to search

Since December 2017 repeateable sections are supported in the Forms Editor

This page is dedicated to setup tips & tricks.

Using default values in the form, with fields coming from the repeated section. Case : we have the field 'Amount' and it is repeated 3 times, but our user only fills in the first and last field: - 1 - - 3


Default setup

Now, if we simply use that repeated field as a default value, we will get:

     #REPLACE-FORMFIELD-repeatingsectiontest||amount||#
     gives:
     1, 3


Set Seperator

You can select your own seperator (even double pipes) by using $$, followed by the seperator you want to use. example:

     #REPLACE-FORMFIELD-repeatingsectiontest||amount||$$;#
     gives:
     1;3

Show all values

Show all values, including the empty entries, by using ++ example:

     #REPLACE-FORMFIELD-repeatingsectiontest||amount||++;#
     gives:
     1;;3

Use first entry as default value for all other

If you want to use the first entry as a default value, use ~~

Create a seperate field, that holds this as dynamic value. You can then use this field as defautl value in the repeated section. With this trick, you can achieve that the first value for a field is copied to all instances below. example:

   #REPLACE-FORMFIELD-repeatingsectiontest||amount||~~#
   gives
   1


Calculate total

Calculating a total amount, based on the repeated fields.

We will use the $$-command, replacing the seperator with a '+', and making that field a calculated field:

    FORMAT('{0:N2}', #REPLACE-FORMFIELD-DANew||Total_Ligne||$$+#)

Total_Ligne is the total amount per section.


Index numbers

We want to have a title for each repeated section, that shows the index, so th e user knows in which row he is working. to show something like (Line nr XXX', do this:

     #REPLACE-REPEATABLESECTIONINDEX-one#

To start from 0, use:

     #REPLACE-REPEATABLESECTIONINDEX-zero#

To use this number in a summary table (see also below), add first a hidden field in the repeated section, that holds:

    #REPLACE-REPEATABLESECTIONINDEX-one#


Summary table

Creating a summary table, using TRANSPOSE

'<table> <tr> <th style="width: 50px; text-align: left; background-color: #D5CAD0;">Nr</th> <th style="width: 75px; text-align: left; background-color: #D5CAD0;">Designation</th> <th style="width: 75px; text-align: left; background-color: #D5CAD0;">Quantité</th> <th style="width: 75px; text-align: left; background-color: #D5CAD0;">Sem.</th> <th style="width: 75px; text-align: left; background-color: #D5CAD0;">Année</th> <th style="width: 75px; text-align: left; background-color: #D5CAD0;">Unit</th> <th style="width: 75px; text-align: left; background-color: #D5CAD0;">Total</th> </tr> <tr> <td> ' + TRANSPOSE('||', '</td><td>', '</td></tr><tr><td>', '#REPLACE-FORMFIELD-DANew||LigneNrHidden||++||#', '#REPLACE-FORMFIELD-DANew||Designation1||++||#', '#REPLACE-FORMFIELD-DANew||Quantite||++||#', '#REPLACE-FORMFIELD-DANew||Livr_semaine||++||#', '#REPLACE-FORMFIELD-DANew||Livr_annee||++||#', '#REPLACE-FORMFIELD-DANew||Prix||++||#', '#REPLACE-FORMFIELD-DANew||Total_Ligne_Formatted||++||#' ) + ' </td></tr></table>'

I refer to the sample forms below

sample forms : - http://dev.ssp7.smt-x.com/Forms/form.aspx?id=406

- http://dev.ssp7.smt-x.com/forms/form.aspx?id=385

Possible Error messages

In case you receive an error message like "Field id xxx has parent field id xxx, but parent field not found in indent collection", you most probably have included your repeatable section within another section. That is no supported functionality and you should bring your repeatable section to the root of the form. By setting the conditions on the section similar to the other section where you wanted to include the repeatable section in, it should work in a similar way.