Hello Max,
I made a form with in it a database Delete action under the Submit tab with the run events "On Delete Fails" and "On Delete Success" to delete a record in a database table.
The delete action depends on a where statement (see picture).
It seems the where state is not used and the run event "On Delete Success" is executed even if I do not fill in anything.
Do I something wrong?
if there is a where statement then it WILL be used, does the delete work but ignore the where conditions ? how did you test this ?
I test it because the message in "On Delete Success" is presented and I do not see the message in "On Delete Fail".
the on Delete fail will only run if there was an error, otherwise the delete will always be a success, even if it deletes nothing
does this answer your main question ?
I still don't get it.
If a parameter in the where statement is not correct then I expect that only the "On Delete Fail" is being executed and not also the "On Delete Success".
I notice when the where statement not have the correct parameter(s) the "On Delete Fail" is not being executed.
are you saying that both the "on delete success" AND "on delete fails" run at the same time ?
What do you mean by "not have the correct parameters" ? what matters is if the SQL statement is correct or not
This is my Delete action.
What I mean with correct parameter is for example that if "pasnr" not equal to the input in {data.quote.nr} or empty the outcome of the where statement is not valid and so the delete will not be performed (Failed) and send me the Message. The Delete Success should not be executed.
I hope it is a bit clearer now.
this is not the meaning of Where in SQL, your where are the conditions of the rows to delete, so whatever where you provide will be used to find a set of rows and delete them
if you need to control when the delete will run then you need the "Run Conditions" behavior, you can then add the rules you need to run the Delete action
is this clear ?
I think, clear so far. Condition rules determine wether a delete action is successful or fail.
Can you give me an example what should I fill in as condition in Value1 and Value2?
I think that what you are trying to do is to check if there are records matching the rules OR nothing matches them in the database table, correct ?
Ok, I have added a new event to the "Delete Data" to run when any records have been deleted:
if zero records were deleted then only "success" runs
The new event will be available in v8.0.35
you can find it now in the downloads area
did it work the way you wanted ?
Sorry Max, but when I trie to open a form I get this error message:
Attempt to assign property "selected" on string
Update:
i installed v8.0.35 again and now I can open the forms but when I trie to copy or restoring a form I get this error message:
Incorrect integer value: '' for column 'parent_id' at row 1
"On Delete Records Found" works.
Mayby also an option "On Delete Records Not Found" so I can warn the user that the record is not deleted?
Hi JoCo
I found the issues you noted and fixed them, and I have also added a new event for "On Delete Records Not Found" as you suggested
thanks for the notes
Happy new year to you!