Initial data of Form only populating Numbers, not text

I'm new to Retool - loving it so far, but I'm struggling to get this to work!

I have a table, a tabbed container and the first tab has a form. The Form Initial data is set to a query (not to the table, as the query has more columns in it than the table). On selecting a row in the table the Form gets the numbers from my query but not the text? I have checked the Form data keys match the columns (I know some of my columns have spaces in the names but this happens for all text columns! - maybe a red herring?).

I'd appreciate any help.

Thanks

Jeremy

@jclutterbuck I think you can either leave that Form data key field blank or set it to {{ self.id }}
What do you have set for the Default value of that field? It should be something like {{GetCurrentAccount.data.account_name}} right?

Thanks for the reply Scott.

I tried setting the Default property to {{GetCurrentAccount.data.['Account name']}} but this doesn't seem to work.

I tried a blank Form data key too, no luck there either.

({{self.id}} wouldn't work because the id of the Text input is "Account_name" because spaces are not allowed, whereas the field/column name is 'Account name', with a space! hence the format above too!

Still no joy...any other ideas?

Also, when I have {{GetCurrentAccount.data.['Account name']}} in the default value I can hover over the JS and it shows me the correct value (albeit indexed): 0 "Tina Davies"

Also, the number fields/columns (e.g. Reference and Age) correctly initialise (directly from the initial data I pressume) without the Default value setting.

Hmmm...

if you type {{GetCurrentAccount.data. what appears after data. there should be a dropdown for choices or an index; if it is an index of 0 then you should type in {{GetCurrentAccount.data[0]. and then see if there are available fields...
difficult to discern what you are doing without seeing it in context.

Dear Scott

Thanks very much for persisting.

That was a great suggestion.

When I type {{GetCurrentAccount.data. I get a list of fields to choose from, one of which if ['Account name']. When I hover on it I get 0 Tina Davies. Using the index [0] I can then hover and get Tina Davies on its own without the 0.

However, with this as the Default value I still don't get anything in the text input.

And with the number fields (Reference and Age) get the values from the Form's initial data rather than any Default value property.

I'm wondering if there's some discrepency with the type. If number's are being loaded correctly but text isn't?

Some context and maybe a clearer explanation of the problem:

We're a Funeral Directors. I have a Computer Science degree (from 25 years ago). We currently have an MS Access database that I have trasfered to Azure and am looking to use Retool as a new front end!

I have a table (table1) with a list of each deceased (Account) and their 'events'. Clicking on one of these should bring up all the detail for that deceased/account.

I have a form (form3) with Initial data set to a query {{GetCurrentAccount.data}} which runs after you click on the table1. The query gets three fields: Reference, [Account name] and Age.

The form (form3) has two input fields: textInput15 (labelled Account name) and numberInput4 (labelled Age).

textInput15 has no default value, but Form data key is set to 'Account name' (to match the field namefrom the query).

numberInput4 has a default value of 0, but Form data key is set to 'Age' (again to match the field form the query)

As you can see, Age is correctly loaded with the value of 80 but Account name still has the place holder value 'Enter value'.

Hi @jclutterbuck, when you are referencing a spaced property name, you should not use a dotted notation but instead bracket notation {{GetCurrentAccount.data[0]['Account name']}. You were able to make age work on dotted notation since it's only a single word. If your property name for 'Account Name' is account_name, dotted notation can work, ie. {{GetCurrentAccount.data[0].account_name}}

You seem to made it work without setting the default value manually on each component inside the form (I'm learning new things here :smiley:); I'll try this one next week on my apps. Let me know if it helps.

Thanks Jocen, I'm so grateful for your input.

I have leanred about the dotted notation and brackets. I realise that spaces in names creates problems. MS Access has a similar issue and I should have gotten rid of them - but instead I learned to cope.

I tried adding quotes and brackets to the From data key (just in case) but to no avail.

I think the "initial data" property of a form is new as a Google search brought it up in What's new! Therefore, I expect most people are learning. However, it is exactly what I need, but I am also worried that it may not have all the kinks worked out yet. Or is it some nuance that i'm not understanding.

Thanks again,

Jeremy

Also, I don;t understand this message...

This is the text that appears if you hover over the Form data key label (underlined with a dotted line).

I tried to see if "Allow wrapping" made any difference but it didn't seem to.

@jclutterbuck adding the [] on your Form data key makes it an array/list so that won't be reflected as a property name in your form1Component.data. Please be mindful of Object/JSON properties and how they are defined, this post defines what is acceptable naming convention for any JSON keys: stackoverflow valid json keys.

As best practice, try not to use any spaces on your column names or property names. Use camel or snake casing.

As for the tooltip there, it just means that if you specify a form data key for that component, that will be used for accessing the data inside the form. i.e. the one I mentioned above form1Component.data.propertyName. If you specified the form data key, that is how you are going to access that in form data, let's use your age component: form1Component.data.age and you get the value of 80 based on the input in the image. The default value of this is {{self.id}} which is the component's initial name (e.g. for the age component, that would have been numberInputX where X could be any positive integer depending on the last increment of your number input component.

I hope my explanation makes sense to you.

Lastly, I'd like to suggest to use aliasing on your GetCurrentAccount query for account name. This way, you won't have to deal with white spaces issues. You can do the following:

SELECT
  Reference,
  Age,
  [Account name] as Account_name
FROM
  Accounts
WHERE
  Reference = {{table1.selectedRow.data.Reference}}

Let me know what you think. Also, can you give us a screenshot of your left panel so we can view your form1 component's JSON properties? you can do this by pressing CMD+B on your mac or on your top pane where the zooming value is, the left most button in that middle group of buttons.

I was having the same problem and fixed by adding a simple transformer to my SQL query.

image

return {{table.selectedRow.data}}

Then, in the form data key just put the column name from the table and the text fields populate from the query.

image

Hope this helps.

Didn't know that was there!

Thanks

Jeremy