Jump to content

loop is skipping records on occasion.


This topic is 7291 days old. Please don't post here. Open a new topic instead.

Recommended Posts

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& "
Link to comment
Share on other sites

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 smile.gif" border="0

Link to comment
Share on other sites

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& "
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This topic is 7291 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

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