May 14, 200223 yr 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?
May 15, 200223 yr 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.)
May 15, 200223 yr 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.
May 15, 200223 yr Author 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"
May 15, 200223 yr 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.
May 15, 200223 yr 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.
Create an account or sign in to comment