Just trying to set a cookie from a button click on a form based on a simple database query.
It deletes the record. I swear it is a select query and not a delete.
Weird… I have a video but would rather not make public. Please suggest.
Thank you.
Hello, your explanation is not really clear.
Maybe you can share some more detailed information of what are you doing exactly in the server action and on your page and what exactly is being deleted from where.
Maybe share some screenshots of what your server action contains and what are you doing on the page.
You can mask out any sensitive data before posting them in the topic.
But the update step runs every time you run the server action. That’s what is setting your records values to null, the as the post vars are not returning a value.
You should put the update record step in a separate server action and run it separately, only when you need to update a record.
think I get it now…pretty much separate folders and server action for everything…the server action thing is taking some time to wrap my head around. I am saying that coming from Codecharge, which was not pretty, but was super simple and very effective for web scrud stuff. All of the server interactions were generated as needed based on the form type and options selected. I know for a developer, Wappler makes it much easier, but for a designer (fashion), it takes some getting used to
thanks for helping me get to the next level with Wappler.
Actually, there is still a problem. I am exhausted by 14 hours of trying to figure this out. But, even with the update and select in separate server actions, I am not only able to null(ify) the contents of ONE record, but AN ENTIRE TABLE just by refreshing the browser. As you said, if the variable isn’t there. I really don’t think this should be allowable in case the user is able to delete a cookie or variable.
I just can’t do another 10 screen grabs, but a video would be more clear if there is another way to send.
Further, I really think a tutorial that includes best practices for the basic/ classic master (single record) detail (editable multi record) would be so useful.
You should not run the update record server action on page load, but on form submit. If it's easier for you to make a video then please do this. Screenshots of the server action steps and what you do on the page are usually enough.
Hi Teodor,
I don’t believe I have the server action for the update set to run on page load. so below are some screen shots. please tell me if you need anything else in greater detail.
and sorry to be a pain, and know that I am causing this, but the questions are not just what is wrong, but also:
should editing/ nullifying multiple records even be possible? It was my understanding that Wappler didn’t support editable grids (ie multi record updates) anyway.
if this is happening because the variable (post or cookie) is missing, isn’t it a little dangerous in case that happens accidentally (or intentionally) and the user deletes all of the records in a table?
so here goes, two things on one page, at top a table connected to a separate server action for select only, and below a form to update a single record of the same table, but on a separate server action with no on page load, or server connect reloads.
that serverconnect_update is there and attached to the serverconnetform1, intended one for updating the record, which is not even being submitted. My understanding being that since the select and update server actions are separated, then there have to be separate serverconnects on the page side, one serving the data for the table, the other for the update form. No dynamic events are set, and still don't get why with no parameter set on a form, it would update multiple records to null.
as for the editable grid, I got that impression from this
the replies and solutions (on blur/ bounce/ hide/ show) seemed like more of an advanced hack vs a built in/ direct feature that hits the database once, with one multi record update. Anyway, a tutorial or example would be great in advance of a built in feature.
You should not include the update record server action as a component on the page, as then it will run on page load.
When you are using a server connect form, it will run only when you submit the form. And with the form, when you applied your validation rules to the inputs it will never be possible to submit it with empty inputs.
ok, guess I assumed that if it was needed on the app side for select, it was needed for update. therefore assume same for input query. that should help a lot.
thanks again.
This continues to be an issue. I clicked a save button while in toggle preview mode of a generated form that is populated by a single record query, and hitting a server connect update (not appconnect) with the condition of a key id cookie, and it works perfectly in the browser when the cookie is present.
What I think happened here, is that in preview mode, there was no id cookie, but it proceeded to update all of the records in the table to null (ie, wiped out table). In my experience (mysql/ codecharge), it was impossible to update a record without the id, of if you really tried, you might affect one record, not the entire table from a form.
As mentioned, a similar thing can easily happen in the browser if you delete the cookie - it updates the entire table to the values of the record you were editing (all records have the same values). Not good.
In the Wappler way, please explain what “doing this properly and validate the data” means. I mean, how do you validate “null” key id variable? It just shouldn’t update, right? Is there a fool proof setting/ method to assure this?
thank you in advance!
Well @sb61
Your post pretty much explains the problem. When doing such operations (update/delete), you should not rely on a value which can be manipulated/deleted/missing.
Why are you using a cookie value for this, when the cookie can be manipulated or removed?
Why not rely on a POST (form) variable and apply server-side required validation to it? This way when the form input doesn’t have a value, no action will be executed.
If you insist on using a cookie, there’s a conditional expression you can add in the update record step, so that it only runs when the cookie has a value.
Can you explain why are you using cookies for updating records?
Also how is the update condition set up in the update record step?