ruthcarlton Posted May 14, 2002 Posted May 14, 2002 I have a DB of events. I would like to create a script that will take the user to the next event. Given that the records may not be in date order, the script obviously must sort first, but a simple, "sort -> next record" always results in displaying the second record. How can I create a script that will simply take the user to the record with the next sequential event date?
Vaughan Posted May 15, 2002 Posted May 15, 2002 Before you sort you need to store which record you are currently on (using a serial number or some other unique identifier) into a global field, then sort, then use a looping script to return to the original record again THEN go to the next record. Set Field [gRecordID, RecordID] Sort Go to Record [First] Loop Exit Loop If [RecordID = gRecordID] Go to Record [Next] End Loop Go to Record [Next] The "Go to Record [First]" step is probably redundant since after sorting the first record is usually selected, but I like being defensive. This simple script could be made a lot more elaborate, but this will suffice. (It does not, for instance, have any code to elegantly handle the situation where there is no record after the original record; and there is no way to break out of the loop in the unlikely event that a RecordID does not match the global.)
goostree Posted May 15, 2002 Posted May 15, 2002 If you want to avoid the loop, just store the unique identifier in a global field, create a self-join from the global to the field that contains the unique identifier, and use the Go To Related Record script step. Then go to next record.
ruthcarlton Posted May 15, 2002 Author Posted May 15, 2002 Both those suggestions are great, except I've thrown another factor into the script. I have 3 "DAY TYPES"; show day, travel day and day off. I only want the script to show me "show days" so now the script starts like... Set Field [gEvent ID, Event ID] Enter Find Mode [ ] Insert Test [select, "Day Type", "Show Day"] Perform Find Sort Neither suggestion will work if the current record is NOT a "Show Day"
Fitch Posted May 15, 2002 Posted May 15, 2002 Looks like you almost have it. You could do this: with a global date field, gDate... Set Field [gDate, Date] Enter Find Mode Insert Calculated Result [">" & DateToText(gDate)] Set Field [Day Type, "Show Day"] Perform Find Sort (by date) Now your next show day is at the top of the list, and you're on it.
falkaholic Posted May 15, 2002 Posted May 15, 2002 Another idea is to create 3 self relations based on the day type. Then have the portal sort by date, then use the go to portal row [next] and go to related record[] combo. Thats should do it. But other idea here are better tho.
Recommended Posts
This topic is 8232 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