Give new person in detached repeat the next number

I have the following issue:
There is a detached repeat for insured persons. Each insured person gets a number “person_number”. This number should automatically be prefilled by “maxpersonnr” + 1 (and still be editable).
Before the update (in A12 2023.06-ext6), the following solution worked:

  • The “maxpersonnr” is computed as 1 for the first insured person and as MaxValue(insured_persons*/person_number) + 1 for all further insured persons.
  • I have a helper field “new_person”, which I set to True once when the “name_of_person” is filled and then stays True forever (but maybe here is the problem, as something changed here in the update?)
  • With a dependency, I set the “person_number” to “maxpersonnr” as soon as “new_person” gets True.

This seems to be a problem with the A12 2024.06-ext3 version. Do you know why (maybe my suspicion above) and how I can solve it differently?

Hi @clara-fleet-yew

You could try using something like:

CurrentRepetition(RuleGroup)

This will return the index of the row in the repeat. As the rows are not zero indexed, this will start at 1 and go up from there.

Check out this 2024.06 model
PersonNumber_DM.json (2.7 KB). You also might be interested in the Monthly Modeling Highlight from 2023, “Indexing in Repeats”.

Please note, your solution from 2023.06 no longer works as it makes a circular reference to the computed field. This no-longer allowed in 2024.06 as it is very deterimental to performance.

This seems to be a nice feature. I will have to clarify if this is a good option, as it does not consider the case, when a former person_number was edited. I will come back, when I got an answer, if this is sufficient.

I’m not sure if I understand the requirement correctly but I just want to make sure the functionality of the computation is clear. The Computation would work like this.

Starting with this data, the person numbers are from 1 to 4.

Person Number Name
1 Aaron
2 Beate
3 Caroline
4 David

Remove Caroline and recompute the values. The person numbers are re-computed and go from 1 to 3. See Intermediary repeatable group instances when adding field instances for more information on why there aren’t any gaps.

Person Number Name
1 Aaron
2 Beate
3 David

Re-add Caroline.

Person Number Name
1 Aaron
2 Beate
3 David
4 Caroline

Customer is fine with it, thanks :wink: