Jump to content
Server Maintenance This Week. ×

Delete last empty record in a list


Greg58

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

Recommended Posts

I have a list with three fields of data.  The first is 'task', and the next two have autofills for 'not urgent' and 'incomplete.  If the task field is empty I would like the record to automatically delete.  I have messed about with 'IF (isempty)' but having no success.  Any assistance would be appreciated please.

Link to comment
Share on other sites

You need to run a script in order to delete a record. You can attach an OnObjectSave script trigger to the Task field - or, perhaps preferably, attach an OnRecordCommit script trigger to the layout -  to run a script that will check if the Task field is empty and delete the record if the test is true.

A semantic note: the term "list" is used in Filemaker for text containing a list of return-separated values. I think you meant a found set here. And if you want to limit the deletion to the last empty record, we'll need a clarification of what exactly "last" means.

Edited by comment
Link to comment
Share on other sites

Thanks for that advice.  Just to clarify, the below image is where I add a task.  My problem is that if I hit the menu button from this page without filling out a task (perhaps I decided not to do it), I get a blank entry as in the next picture.  I would like to have that blank task delete if there is noting in it.

Thanks for any help you can give.

image.png.fb01d63198f937d3fdeee75dbbe07b99.png

image.thumb.png.c334c47a53b92d154870c344098823db.png

Link to comment
Share on other sites

3 hours ago, Greg58 said:

The add button is to add the task to the db.

I am afraid that doesn't tell me much. When I ask what exactly does a button do, the expected answer is "it runs a script that does [a list of steps]". The only thing I understand from your description is that the task is added to your table even if you do not press the  Add button. So I am guessing that a new record is already created before you start filling those fields shown in your screen shot. If this is so, and you want to prevent the Task field being empty, you should validate the Task field as not empty. That will prevent the new record from being committed - and the only remaining question is how to make user experience more pleasant by not exposing them to validation error messages.

 

 

Edited by comment
Link to comment
Share on other sites

Thanks for that.  I did the validate as 'not empty' and that does fix the problem, but as you say not a great user experience.  I will work on that.  :)

Thanks again.

Greg

Link to comment
Share on other sites

2 hours ago, Greg58 said:

as you say not a great user experience.

There are two possible ways to approach this:

1. Prevent users from committing the record in any other way except by clicking the "Add" button; then you can run a script that will check if the field is empty and either commit or refuse, giving a more user-friendly error message; 

2. Script the creation of new records, using either variables in a custom dialog or global fields for user entry.

Link to comment
Share on other sites

This topic is 1841 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.