Jump to content
Sign in to follow this  
Gismo12

Delete All records if Container is empty

Recommended Posts

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

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

 

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

 

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

Share this post


Link to post
Share on other sites

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. 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Similar Content

    • By Answers
      Our people out in the field take photos which go directly into the container fields, we would like those photos to automatically transfer to the camera roll/gallery. I know there is an export command and that would allow the techs to export and choose the location, save image etc... But that is a tad too complicated for them.
      Any suggestions on how to automate this process, the script for export field contents doesn't have a choice to save to camera roll.
      Thank you!
      Caroline
    • By innodat
      Does anyone know how to fix an image from appearing too small within a container in WebDirect? In FMP it fills the container. Tried to "play" with most settings relating to containers, including margins, frame, etc. - no success. The problem presents itself in Safari in macOS Catalina, as well as Edge on Windows 10

      See image attached.
      I sure hope this isn't a bug! Because if it's a bug then it will get fixed... well, never. 
       

    • By stuee
      Hi,
      I have a container which i click on and take a photo on my ipad and it shows in the container. I want to be able to click that image on the ipad or pc to view the image full size after. How can i do this?
    • By Jhon Doe
      Hi everyone
      i'm new in filemaker, i'm using filemaker 17 and currently i'm involve in a proyect but i have a problem that i can't resolve, maybe someone of you have had the same problem.  
      I'm saving images in base64 format in a database to show them in a layout with web viewer,that doesn't has any problem, the problem is that i'm using a portal and i didn't know that portals don't support web viewer. I have to display those images but i can't remove the portal since i didn't do that layout and it has scripts using it along with the portal, is there a way to show images saved in base64 without use web viewer? (I've already tried to use container field but it only show a "?" image 😓 )
       
      My English is not the best but I tried my best ,Thanks for your help
       
    • By Asu
      Hello FM Mavens, 
      I am likely missing something. 
      I have a script step that calculates the dimensions of an image in a container field. There are many such fields so the script should work with any arbitrary one. 
      I get the name of the field by using script parameter Get(ActiveFieldName). 
      Let's say I have a container field "cont1". The script is triggered by entering the field.
      I am trying to calculate the height of the image by using 
      GetContainerAttribute (Get ( LayoutTableName ) & "::" & Get ( ScriptParameter ); "height" ) The results are question marks - I am not sure why. If I explicitly identify the fields then the expression works. 
      Tried the same expression (Get ( LayoutTableName ) & "::" & Get ( ScriptParameter )) in the script step "Set Field by Name" and it worked, which means that the expression correctly identifies the field the script is attached to. Then why is it not getting it the first step? What's wrong with the calculation? (FM17)
      Thanks
      Asu
       
      (I hope I posted it in the correct section)
×
×
  • Create New...

Important Information

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