Jump to content
Sign in to follow this  
ddreese

Loop Problem

Recommended Posts

I have another file showing the related records of the "constellation_join" file. Say I get 3 matches. The script in the "constellation_join" file is supposed to loop through all the results, make a duplicate of each record and change two fields on each record. The script is as follows:

Goto Record/Request/Page [First]

Loop

Duplicate Record/Request

Set Field ["Ongoing CY ID", """"]

Set Field ["CPS Investigation ID", "relationship::CPS Investigation ID"]

Goto Record/Request/Page [Exit after last, Next]

End Loop

What is happening is it only goes to the first record, duplicates it, and then exits the loop. I've put pauses in, and it does list all the records in the found set (i.e. 3 out of 170), it just seems to quit after it's done with the first record.

I've done loops before, and I can't find any differences loop-wise that would be causing it to do what it's doing. I'm sure it's something completely simple, but it's driving me crazy.

Share this post


Link to post
Share on other sites

If you don't have the records uniquely sorted, then the duplicate will appear at the bottom of the found set. Then when you Go to Record/Request/Page [Exit after last, Next], you have passed the end and the loop is complete.

Try sorting the records by a unique field that will be the same in the duplicate. I usually renumber a sort field from 1 to X, and use that. Then your duplicate will appear directly underneath the current record, and Go to Record/Request/Page [Exit after last, Next] will work as desired.

Share this post


Link to post
Share on other sites

Duplicate can work 2 different ways. If the records are Unsorted it will put the duplicate at the end, which is what's happening. Hence it exits prematurely. If however you Sort the records (can be by anything, even a Constant=1, which doesn't appear to do anything), then the duplicate will be put immediately after, and it stays sorted, so you can Loop. That's what you'd want.

Share this post


Link to post
Share on other sites

Yikes! Queue is right. It has to be by a unique ID. I must have been thinking of something else (or not thinking at all :-0)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.