October 26, 200124 yr ok i have this script, what it does it loop through all the records in a relationship (Orders_) and e-mails someone the Order ID Number. then it stores the Order ID Number the "hold" field, so it know that the record has already been e-mailed. NumofPortalRows is just a field that tells me home many portal rows there are. gPortalNumber is a global that keeps track of what portal row i am on. Now the script works most of the time. However, sometimes the script will skip a record. Its totally random when it does it, sometimes it will skip the first record, sometimes one in the middle. Most of the time it won't skip a record at all. If it does skip a record i can run through the script again and it will pick that record up and e-mail it. So, my question is, do you see any problems in my script that would be causing it to randomly skip a record. code: If[ NumofPortalRows = 0 ] Exit Script End If Set Field [ gPortalNumber, 1 ] Loop If [ PatternCount(hold,Orders_ :Order ID Number) < 1 ] Set Field [ hold, hold &Orders_:Order ID Number& "
October 26, 200124 yr The problem could lie in the line Go to Portal Row [ Next, Select entire contents, Exit after last ] I have recently had many problems with this due to the fact that if the focus is lost from the portal (possibly when you set a field or send mail) then when this command is executed the portal goes back to row 1. Try using Go to Portal Row[ gPortalNumber ] [ By Field Value..., Select entire contents ] instead. Since you have the global field there anyway you might as well use it to its full potential. To exit the loop you can use a comparison with Status(NumPortalRecords) (or whatever that command is) and the number in your gNumberPortal field. Hope this help
October 26, 200124 yr Author you know what, i had that before(in fact that was the whole reason i created the global field), and for some reason i took it out. i forget why i did it. i really don't even remember taking it out.. well anyway, here is my edited script. code: If[ NumofPortalRows = 0 ] Exit Script End If Set Field [ gPortalNumber, 1 ] Loop If[ PatternCount(hold,Orders_ :Order ID Number) < 1 ] Set Field [ hold, hold &Orders_ :Order ID Number& "
October 29, 200124 yr Author ok, even with my new and improved script it still skip a record sometimes. I know that a more practical solution would be to actually run a script from the related database, but unfortunately that is not possible in this situation, i can't really explain why. but, needless to say, i need it working through the portal. Any more ideas?
October 29, 200124 yr In the If Statement...possibly move the "Go To Portal Row" command above the "Set Field" command. You might have a reason for doing it the other way around but at a quick glance it seems odd. Hope this helps
October 29, 200124 yr Author thanks, now that you mention it, it does look a little odd. well, i guess we will see how this works.
November 2, 200124 yr On skipping records in a loop -- I've had this same problem...then I found an obscure article somewhere that mentions that you need to first go to the last record and move backward ["go to previous record, exit after last" I think] in your loop script to avoid skipping records. Since trying this, I haven't had this problem anymore.
November 5, 200124 yr The looping backward technique is for a different problem. It avoids the skipping of records if you have an omit or delete step in your loop.
Create an account or sign in to comment