Form update not working

this form won't update the database and I can't figure out why. I've done it as pictured and hand-wrote the sql but nothing works. What am I doing wrong??

image

Hi @BubbaHoTep Are you showing this data in a table?
If yes, You can pass table1.selectedRow.id against id and it will work.

If this does not help you can schedule a call with me for free solution.

Hey Chris,

Are you getting any error, if so, which one?

It would seem you're referring a variable where you id is stored? Is that correct? If so, try checking the status of your variable to verify if the value is being stored correctly, and if you don't need to add an index to access it, e.g. idInput.value[0]

If none of this does it, then do share a couple of screenshots of where idInput is being taken from so we can help.

The data is in a form. I have tried referencing it by {{ form2SubmitToCfpSubmissions.id }} as well as {{ form2.data.id }} and both of those using the array [0] and the data never updates. When I mouseover the {{}} value it shows properly.

This form is where the data is:

The submit button action:
image

Hey @BubbaHoTep ,

Thanks for the explanation and additional info. What error does the query throw?

I'm guessing that because you have a component for your id (which is not usually best practice) this may be passed via form2.data as well (together with any other component that is within your form component). Try hovering over form2.data and double check that all of the keys within it match a column in your table. If not, you can remove them with the following:

(() => {
  const { id, keyToRemove1, keyToRemove2, ...filteredData } = form2.data;
  return filteredData;
})()

I don't see any errors anywhere--is there a specific place to look?

I only have a component for id because i need to somehow update the right row... when the form is submitted I need to somehow send that field.

When I hover on form2.data it appears as if all the keys are there and matches the table.

You can see query errors in the console:

So, as you are trying to edit an existing record, you shouldn't be passing id in the form2.data array. Try changing the object to

(() => {
  const { id, ...filteredData } = form2.data;
  return filteredData;
})()

No errors on console
image

@MiguelOrtiz I don't understand where that code you posted goes. I just am using the UI to do this--the whole point of me using Retool is so I don't have to write javascript type things.

Hey @BubbaHoTep,

So, the query is running succesfully, have you checked your database to see if the data is being edited correctly?

If not, you can click on the form2SubmitHandler query in the console to see which values are being passed, and see if th eid is the correct one.

With regards to this

...the whole point of me using Retool is so I don't have to write javascript type things

Retool is a "low-code" (opposed to no-code) tool, and its mostly aimed at developers. You will struggle to build complex apps if you don't want to use javascript at all. With the help of ChatGpt you can learn the basics (or using retool University) and make your life much much easier. Without javascript, I'm sorry to say this but your apps won't get really far.

Hi @BubbaHoTep

How are you verifying that the query is running correctly?
How are you setting the id in the idInput component?

Can you jump up on call with me it will be a basic solution but it is difficult to understand this way that how are you implementing the stuff.

Please let me know if you can export JSON file and share here so we can import in our account and check where the fix is required.

I get that. i was a little frustrated because this seems like the simplest use-case of loading data in a form then updating the data--I think it should be dead simple to do this since it has an id and nothing complex--just update the row with the new data.

I understand your frustrations. Maybe Office Hours would be a better way to support you. We help users live on discord on Tuesdays and Thursday from 11:00am to 12:00pm PT.

I suspect this is a typo or something small. Happy to help you async before then if you can answer a few questions that would help greatly.

  • How are you verifying that the query is running correctly?
  • How are you setting the id in the idInput component?

when I select the data, I select out everything including the ID (even though I already know it), so it should be available both via the form and the query param. In the form I just marked it as hidden. I validated that the value is correct both ways (the data is loaded via the query string param) and when I mouseover the the data result.

For checking the update, I reload the page with the form which reloads the data and observe my changes did not get committed to the DB. I also used a direct SQL query and can see that the data is not updated. When I say it is running correctly, I mean that it does not generate any kind of error.

Thanks for the tip on office hours--if I can't figure this out I'll try to join.

If you want to send me a JSON export with hard code query results I can debug!

@BubbaHoTep Please verify if the issue has been resolved. The primary issue was that the data format was incorrect during the initialization of the form. Moreover, you can obtain the record ID from your URL parameters.

Thanks! But I made the changes to match your pictures, and I still am not getting the database updated when I submit. It looks like from the screenshot yours did; I'm not sure what is going on. Console has no errors.

image
image

Your submit button should point to query form2SubmitToCfpSubmissions

I hope you did these changes in this query

You can create a new application by importing following JSON file.
test.json (85.9 KB)

I have also recorded a video for you to the application. My items - Awesome Screenshot