I would say:
Get the 'Go to Record/Request/Page [Next] one line down (out of the If-statement) and add: 'exit after last'.
That should do the trick.
Thank you Wouter, that almost worked. I'm testing with 5 images with a related Product ID. The script now completes but it leaves the 2nd and 4th images for some reason, can't understand why.
OK, I think that is because you deleted the record (1), so you get to record 2 automatically, by going to the next you are on 3.
Maybe you should change next to first (everytime you delete a record, you go to the first of the remaining).
I expect the loop to end when there is no record left.
Correction on my last reply:
Go to first
Go to Record/Request/Page [Next] - exit after last
This will prevent an endless loop in case your if statement returns a false.
Thank you, Thank you!! Works great!
Glad I could help.