Populate fields between repeats

1116
4
04-30-2021 12:02 PM
AndrewPadilla
Occasional Contributor

Hello Geonet Users,

I am having difficulty populating fields between repeats. My workflow is as follows: First, several records are created in Repeat 1. Secondly, one record (w/multiple fields) is entered into Repeat 2. I need the fields from Repeat 2 to populate all records created in Repeat 1. Currently, only the last record in Repeat 1 is being populated. The remaining records have a refresh button. The problem with the refresh button is that the fields will be hidden. I have tried a couple of different approaches: calculating the field outside of both repeats and using the  indexed-repeat formula. Neither seem to work. Maybe some JavaScript function might help, but I am not familiar with writing JavaScript. Any help with this will be greatly appreciated. Attached is an example file. 

Thanks,

Andy

0 Kudos
4 Replies
DougBrowning
MVP Esteemed Contributor

I think it is the using a field called calculation.  I changed it to calculation22 and now it works.  It is not on the reserved list but I would not use it.

DougBrowning_0-1620228078650.png

 

Hope that is it

0 Kudos
AndrewPadilla
Occasional Contributor

Hi Doug, 

Thanks for taking a look, I should not have used "calculation" as as field name. I made the change as per your suggestion though if you add multiple people before adding the HHID/City on page two only the last person

repeat will be populated with the values. The other records in the repeat have a refresh button next to them.AndrewPadilla_0-1620409003752.png

Since they will be hidden fields they will not recalculate once created. As a work around, I ended up putting a relevant HHID and City field before the Person repeat which populates the hidden HHID and City fields. I was trying to avoid having to create extra fields but ended up doing so this time. Attached is a revised example. Thanks again for taking a look. 

0 Kudos
DougBrowning
MVP Esteemed Contributor

Did you try calculate type instead of hidden?  Those should fire diff than text would.  Sorry still not really getting your workflow.

0 Kudos
DougBrowning
MVP Esteemed Contributor

Oh I just saw now you are using repeat count.  That is prob your issue.  Using repeat count preloads all the repeats at the start.  This can cause all kinds of issues with calcs.  I have posted on this but I cannot find it.

In the end I had to remove all my repeat counts as they just do not work right.  3.13 is supposed to tackle a number of these.  Instead I count and they tell then with a constraint if they add too many.  Works much better.

Try removing repeat count and see.  I am not sure why you would use a repeat for just 1 record really.  Maybe just testing.

But yes it will not go back through all the repeats and populate them if you change it later.  I would not show the repeats until they pick a city then nothing to worry about.

Normally I also only push the key into a repeat otherwise you are just double storing data.  If you say want to change the city then you have to find and change all of the subtables instead of just changing it in 1 place.  They can get mismatched easily.  It would be like storing your address in each individual bill vs just changing it in your person record.

Well hope that helps.

0 Kudos