Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 2202 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted (edited)

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
Posted

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.

  • Like 1
Posted
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 )

?

 

  • Like 1
Posted
1 hour ago, comment said:

 

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


IsEmpty ( YourTable::Containerfield )

?

 

True...

  • Like 1
Posted

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

 

 

Posted

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

Posted

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

  • Like 1
Posted

 

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

Posted

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. 

This topic is 2202 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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