Title
Moving images in repeating container field to first position
Post
Hi,
I have a repeating container field (10x) where my users can insert photos. Sometimes, they have inserted them in the later positions rather than starting from the left at position/field #1.
Is there any way I could go through all my records, search for photos in the container field, and if they are, move them if necessary in such a way as to make sure they fill up the repeating field starting at position 1?
Thank you, I can't seem to find anything online related to working with repeating container fields and their contents.
That's because a repeating field is (and should be) rarely used for this. A related table with one record for each image is more flexible and avoids this issue. It's pretty simple to use Import Records to copy this data from the repeating fields into such a table with the data in each repetition split into a separate record. This will then also solve your issue of images not being filled in from the first repetition onwards as any empty repetitions will not produce a record in such a new related table.
Without such a design change, you are looking at a fairly complex script that loops through the records, and on each record loops through the individual repetitions looking for empty repetitions and using a third loop to move the images from repetition to repetition when an empty rep is found.