Jump to content

Delete Record/Request loop not working


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

Recommended Posts

Hi

 

I have this strange problem in one script I am using to delete child records.  The script is in the attached file.

 

For example when there are 20 child records then the script finds 20 records, but when the script goes into the loop script it only deletes half of the records, so when I press the button "Delete" once there are 10 records left. When I press the button again there are 5 records left and so on. Can anybody point out what I am doing wrong here.  The loop part does not loop though the found set.

 

Regards,

Reynir.

Filemaker - Delete related record script.pdf

Link to comment
Share on other sites

Update:

 

When I create another script to run this script six times it does what I want it to do.

 

I forgot to mention.  It is written in FileMaker 11 Advanced.

Link to comment
Share on other sites

Hi

First of all we didn't need to use the looping since you have to delete all the found set records which can be done through Delete All Records script step.

And for your information the looping condition in the script is incorrect.

As, when you delete one record and  move to next record, it skips one record since the after the deletion of the first record the second becomes first.

So in the script the condition should be:

 

Go to Record/Request/Page[First]

Loop
Delete Record/Request [ No dialog ]
Exit Loop If(Get(FoundSet)==0)
End Loop
 
Now the above script will work correctly.
Link to comment
Share on other sites

Priyabatra: no, that does not work.

Did you actually TRY, TEST, and OBSERVE what you are suggesting?

Deleting a record automatically puts you on the next record.

The go next command therefore causes you to skip a record.

The loop isn't necessary; you could just use the delete all records command.

If you want to keep the loop method, even just to understand it, just eliminate the go next command and put as the first step inside the loop a statement

Exit loop if[ get(found count)=0]

Link to comment
Share on other sites

Exit Loop If(Get(FoundSet)==0

Not meaning to nitpick (but being accurate is important ) ... using == on a number isn't necessary and it will work fine with =0. Also there is no Get(foundSet) but rather Get ( FoundCount ). You can also use Boolean test for step instead of:

Exit Loop If [ not Get ( FoundCount ) ]

And you don't need Go To Record/Request/Page [ first ] ... as Bruce says, it will gobble them all up anyway without starting on the first one. :laugh2:

But Delete All Records[] can be used instead.

Edited by LaRetta
Link to comment
Share on other sites

Priyabatra: in your original reply you only stated that the Go to Record/Request/Page[First] should be added outside the loop.

 

Then - after reading my reply - you completely changed your response and included the method that I described.

Except (as noted by LaRetta) you used another invalid statement; which was invalid in two ways.

 

You cannot use "==" in a calculation. It can be used when performing find operations - but not in a calculation.

There is no such function as get(foundSet)

Link to comment
Share on other sites

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