elvis_impersonating_penguin Posted October 26, 2001 Posted October 26, 2001 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& "
FUBAR Posted October 26, 2001 Posted October 26, 2001 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
elvis_impersonating_penguin Posted October 26, 2001 Author Posted October 26, 2001 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& "
elvis_impersonating_penguin Posted October 29, 2001 Author Posted October 29, 2001 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?
FUBAR Posted October 29, 2001 Posted October 29, 2001 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
elvis_impersonating_penguin Posted October 29, 2001 Author Posted October 29, 2001 thanks, now that you mention it, it does look a little odd. well, i guess we will see how this works.
cpbatwes Posted November 2, 2001 Posted November 2, 2001 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.
BobWeaver Posted November 5, 2001 Posted November 5, 2001 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.
Recommended Posts
This topic is 8424 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now