AnsweredAssumed Answered

Re-doing a search at the end of each loop - is there a better way?

Question asked by russbrad on Aug 21, 2012
Latest reply on Aug 21, 2012 by russbrad

I'm performing a script to duplicate an item along with its related records, as I outlined here:


The related records are line items, whose data is populated by copying from records in the product table. When duplicating the line items, I'm changing their price group, so they need to get their data from a different product. So instead of using Duplicate Record, I'm using New Record and giving each line item just the information it needs to get the data from the appropriate product.


However, I'm looping through a found set of records to do this, but when I use New Record, the new record adds itself to the found set, so the loop is thrown out of sequence, and I get unpredictable results.


So what I've resorted to doing is as follows:


  • perform the initial search (blue)
  • record the appropriate bits of information to manually increment through the records (orange)
  • start the loop (green)
  • after performing the New Record operations, redo the search (yellow)
  • apply the manual looping logic (orange).

Multiple Searching.jpg


Is there a better way of doing this? What would be ideal would be the ability to retain a found set and return to it later without performing the search again, but I'm open to suggestions.