Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

delete and go to next record script

Featured Replies

hi

i have a problem doing a loop that deletes records;

(btw - is there a way to copy stuff from the script dialog box!?)

so the loop works fine but when deletes the record instead of going to the next record - it jumps one - i understand that the logic is that if deleted "this" one the "next" record is already there and you don't have to use the "go to the next record" command but what if i don't need the "next" record deleted but the fifth after that.

like i need a loop that goes through a db and deletes only certain records - they might be consecutive records or not...

i hope this explanation gives an idea of my problem...

  • Author

nevermind...

You've obviously figured out that whenever you delete or omit a record inside a loop, the new current record is the one immediately following the one you deleted. So, when you execute a Go to Record/request[next] step, it has the effect of skipping that record.

The simplest solution to this problem is to start at the last record and step backwards through the set of records using the Go to Record/request [previous] step.


Go to Record/request [last]

Loop

If [<<condition for deleting record>>]

Delete record

End If

Go to record/request[previous][exit after first]

End loop


The other technique is to use an If/else construct like this:


Go to Record/request [first]

Loop

If [<<condition for deleting record>>]

Delete record

Else

Go to record/request[next][exit after last]

End If

End loop


A word of warning though, if you delete the last record in the set, make sure that the script is properly set up to terminate without getting into an endless loop. I've encountered certain situations where skipping the last record causes the 'exit after last' to fail.

(btw - is there a way to copy stuff from the script dialog box!?)

Inability to copy in a number of dialog boxes was a bug in 5.5 for Mac... try downloading the latest updates.

No, there is no way to copy and paste script steps in any version of FM pro.

Another way of dealing with this would be to use the "Omit Record" step instead of delete. Your script would go like this:-

Go to Record/request [first]

Loop

If [<<condition for deleting record>>] Omit record

Else

Go to record/request[next][exit after last]

End If

End loop

Show Omitted

Delete All Records

This way you should avoid getting into an endless loop.

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.