repeat subforms for each data item

Avatar

Avatar

utente2

Avatar

utente2

utente2

01-08-2020

Hello,

I would like to ask a question about the "Repeat Subform for each data item" option present in the Aem Forms Designer in Object-> Binding. If I connect the element I want to repeat to the data of the XMl file through the "Data binding" field and select "Repeat Subform for each data item" the result I see in the preview is correct but it gives me a warning like "The maximum repeat value for this subform is set to a higher value than the data connection" if the number of connected data is equal to 1. Is it possible to use the option whether the number of data is > 1 or equal to 1? I have tried with different values also on "Min count"and "Max count" but the warning remains.

View Entire Topic

Avatar

Avatar

Kosta_Prokopiu1

Employee

Avatar

Kosta_Prokopiu1

Employee

Kosta_Prokopiu1
Employee

04-08-2020

Hi,

you basically confirmed my assumption. If you use more than 1 fragment as shown below you run into the "data depleated" situation.

Here a basic XML sample which should match your data

kprokopi_0-1596532278773.png

The first repeating subform (no matter if in fragment or directly placed in the design) will depleat your data which is run through from top to bottom during render and never goes back to the beginning. Should subform 1 only read 2 elements, subform 2 would get the one left. But as your subforms dynamically use all employees records subform 2 will never get anything. That you still see one empty has to do with the fact that normally minimum one instance of the subform is thrown but no data for your fields are there.

You could now do the following:

kprokopi_1-1596532508942.png

Assign hr1 to the first, hr2 to the second ... - problem here is, that it not only duplicates/triplicates the data but you are not flexibel with your forms - you would have to change the data collection with every form depending on the number of fragments used - and if you don`t know how many would be there at render time - well then things become really ugly and unmaintainable.

 

You probably have only one option left. Use the data from the dataset directly and NOT bind it. Use a script in EVERY fragment which loops through the data, uses the instance manager to throw a new row and fill the value of each field. This would not deplete the data, and by implementing it consistenly, you do not have differing approaches to filling the fragments.

 

This is too complicated to quickly conjur up as an example - I don't have time for that. But I hope that it will help you towards a solution.

How experienced are you with the scripting in XFA?