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 All records if Container is empty

Featured Replies

Hi,

How will I approach to delete all records in a table where the container is empty.

I tried a few scripts but ran into problems with most of them.

Loop stayed in a loop

I tried calculating container length and delete if length is zero, but the field does not calculate to a zero even if i set default to zero

Edited by Gismo12

Could you explain in a little more detail what you are doing.  I'm curious about a need to delete all records.  Is this in Import, do something, delete?

 

You could try this test.  Name your container in the inspector "Container".

IsEmpty(GetLayoutObjectAttribute ( "Container" ; "content"))

Will return 1 if the container is empty.

Although I'd really make back ups and test it.  If the script is called from the wrong context, or hits an error, you may delete the wrong records.

4 hours ago, Gismo12 said:

all records in a table where the container is empty.

Actually, this problem is discussed in the help:
https://fmhelp.filemaker.com/help/17/fmp/en/index.html#page/FMP_Help/finding-empty-non-empty-fields.html

 

54 minutes ago, Steve Martino said:

IsEmpty(GetLayoutObjectAttribute ( "Container" ; "content"))

 

Why go to through the layout, instead of directly to the horse's mouth:

IsEmpty ( YourTable::Containerfield )

?

 

1 hour ago, comment said:

 

Why go to through the layout, instead of directly to the horse's mouth:


IsEmpty ( YourTable::Containerfield )

?

 

True...

  • Author

Thank you, but it does not seem to work.

I have 152 records, i have a picture in one of the records, when I run the IsEmpty scripts, all 152 records are deleted.

I tried below script but stays in loop.

Here is my script:

image.png.f21799cb34aca700f9c2c4586ad5e70d.png

 

 

Your script looks nothing like what was suggested. 

  • Author

I have tried the code as suggested, but as I said, It remains in the loop and nothing else happens.

It is not deleting the records.

 

image.png.982201a5430a1574cc057297b5682208.png

You have to be more meticulous with your coding. You have: 

Go to Record/Request/Page [ First ]

inside the loop, where the example script has:

Go to Record/Request/Page [ Next ; Exit after last: On ]

so of course the loop never exits.

 

Also, you are omitting the empty records, not deleting them. If you want to delete them, then - after the loop has terminated - switch to Show Omitted Only[] and do Delete All Records[]. Or delete them in the first place while still inside the loop. What you have now will delete one record - and that record is not empty (or it would have been omitted).

  • Author

 

20 hours ago, comment said:

You have to be more meticulous with your coding. You have: 


Go to Record/Request/Page [ First ]

inside the loop, where the example script has:


Go to Record/Request/Page [ Next ; Exit after last: On ]

so of course the loop never exits.

 

Also, you are omitting the empty records, not deleting them. If you want to delete them, then - after the loop has terminated - switch to Show Omitted Only[] and do Delete All Records[]. Or delete them in the first place while still inside the loop. What you have now will delete one record - and that record is not empty (or it would have been omitted).

I have made the changes as suggested, it still remains in the loop.

image.png.0851c977bcedaba25c78062abdfe15fd.png

I am sorry to say this, but this is getting ridiculous. You have no action specified for when the If[] condition returns true (it should be Omit Record). I said before that you need to pay more attention to detail. You have a perfect example given to you in the help, yet you can't follow it. I will not continue playing this game. 

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.