Jump to content

Set error captrure (on)


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

Recommended Posts

It's a quick question and just need to make sure its meant to happen:

At the beginning of a script:

Set error capture (on)

Set $temp = header id

Go to layout step - where the layout's underlying table is not linked to the starting TO

Find command based on $temp

Check its the right number of records to delete

then delete records command

It seems that the "set error capture on" stops the go to layout from appearing which is fantastic

just i cant see that its meant to happen in any documentation

is this OK?

Link to comment
Share on other sites

This doesn't address your question, but why are you finding child records this way? You should have a relationship between the two tables and use Go To Related Record script step.

I don't think the Set Error Capture is preventing the refresh of the window. You do have to trap, especially if you intent is to delete the found set!, to see if there are any child records. For example,

If ( not isempty (Parent::Child(fieldid))

GTRR (Parent::Child)

Delete All Records (no dialog?)

End if

Remember GTRR fails if there are no children, and you certainly don't want to delete all records in your parent table.

Link to comment
Share on other sites

Hi,

Thank you so much for posting - I have implemented your method (only took me a little while to work out that with this approach you have to delete the header/parent record last : ! - I am not that experienced but I am learning fast!)

I have really inherited this app (quite large) and on looking through similar routines none of them use a GTRR approach (anywhere)

Is this a programmers generational thing

It seems a lot more efficient to me to use the gtrr approach

Anyway once again many thanks

Simon

Link to comment
Share on other sites

having done all that ...

is this gtrr method a lot "safer" than using the "delete related records in this table when etc" option from the relationship?

I seem to remember somebody saying that you could get cascading deletes with the relationship settings.

Cheers

Simon

Link to comment
Share on other sites

In your first post, you didn't mention that your goal was to delete both the parent and its children. If that's the case, just use the cascading delete (the delete records checkbox in the relationship). Actually, any mass delete/edit is potentially dangerous. That is why they are typically proceeded with a dialog (either your own scripted one or use FM's built in one).

Link to comment
Share on other sites

Hi,

I apologize, in my first post I was just trying to find out about a side effect of "set error trapping" etc, and not very well phrased at that.

In the event, having now learned a whole lot more )I have now used the relationship setting to delete the child records

(I do have plenty of warning messages in the script :-) )

Thanks

Simon

Link to comment
Share on other sites

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