Forums

Where statement in Delete Action

JoCo 26 Dec, 2024

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?

Max_admin 26 Dec, 2024

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 ?

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
JoCo 27 Dec, 2024

I test it because the message in "On Delete Success" is presented and I do not see the message in "On Delete Fail".

Max_admin 27 Dec, 2024

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 ?

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
JoCo 27 Dec, 2024

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".

JoCo 27 Dec, 2024

I notice when the where statement not have the correct parameter(s) the "On Delete Fail" is not being executed.

JoCo 27 Dec, 2024

In V7 it works perfect.

Max_admin 27 Dec, 2024

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

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
JoCo 27 Dec, 2024

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.

Max_admin 27 Dec, 2024

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 ?

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
JoCo 28 Dec, 2024

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?

Max_admin 28 Dec, 2024

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 ?

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
JoCo 28 Dec, 2024

Yes Max, I only want to check if the delete action was successful or not.

Max_admin 28 Dec, 2024
Answer

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

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
JoCo 28 Dec, 2024

Thank you very much Max. I wait for v8.0.35.

Max_admin 28 Dec, 2024

you can find it now in the downloads area

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
JoCo 28 Dec, 2024

👍

Max_admin 28 Dec, 2024

did it work the way you wanted ?

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
JoCo 28 Dec, 2024

Sorry Max, but when I trie to open a form I get this error message:

Attempt to assign property "selected" on string

JoCo 28 Dec, 2024

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

JoCo 28 Dec, 2024

Save Settings in the Forms list give this error : Error updating settings

JoCo 29 Dec, 2024

"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?

Max_admin 30 Dec, 2024

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!

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
JoCo 30 Dec, 2024
1 Likes

Thanks Max.

Happy new year to you to!

You need to login to be able to post a reply.