Jump 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.

Script-trigger to delete records automatically

Featured Replies

Hey everyone,

I am looking to get some advice on how to define a script-trigger that will automatically delete records that have the "AmountOnHand" field = zero. A little background on the reason i need this solution is that my database manages chemical inventory. Each chemical has a particular lot #, therefore each chemical ingredient needs a separate record. This creates the problem that when we use up all of a chemical the record still remains,even though we are using an ingredient with a different lot #. I've thought about running a weekly report that finds the set with "AmountOnHand" = zero and then deletes the found set, but anyone have any suggestions or a better way? Any help is appreciated!

Is your question how to attach a script trigger to a field, or how to create a script that deletes records, or what?

Does a user manually set the AmountOnHand field to 0?

  • Author

Hey Fitch,

I know how to attach a trigger to a field, I'm guessing the trigger i want is "OnObjectModify", I just want to make sure i'm clear on the script steps needed to solve the problem in my first post. My lack of experience might show through because i want to use the IF function for my script steps but i'm not sure if thats the way to go!

No the "AmountOnHand" is automatically reduced (to zero) through the ingredient being used up in a chemical Formulae.

This creates the problem that when we use up all of a chemical the record still remains

Why is this a problem? Don't you need the record for history purposes?

It's not clear to me how your tables are related, what fields are in what tables, and what layout (based on what table occurrence) you are on when the quantities get changed, and whether that process is scripted or not.

Your trigger would most likely not be on object modify, but rather on object validate, exit, or save.

If[ AmountOnHand =0 ]

... do stuff here

End If

Create an account or sign in to comment

Important Information

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

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.