Cannot read properties of null - update query

When I start the App and open the debug I see there are a list of error's

As i understand it, ReRool is traying to run the "Update_itemOrgDescription" before I have triggered this with a event. Why and how do I stop the App to return errors?

I have some tables multiple tables.

  • Tab 1
  • dropdown selection.
  • table 1 is using where {{dropdown.selectedItem.value}}
  • table 2 is using where {{table1.selectedRows[0].id}}
  • table 3 is using where {{table2.selectedRows[0].id}}
  • formtable3 Data source {{table3.selectedRows[0]}}
  • text field "Description" is pupulated with data using from data key
    with a event handler
    image

update query: "Update_itemOrgDescription"
image

Note that I'm a new beginner and I greatly appreciate your help.

Hi @Thore - I also experienced this. My way of resolving this is by fixing each occurrence by slightly adjusting the code.

For example, if dropdown.selectedItem may be undefined sometimes then adjust code like {{dropdown.selectedItem.value}} with something like {{dropdown.selectedItem && dropdown.selectedItem.value}}

Hope this helps

Hi @preshetin

I added this in all my Get_query's but I still get the "Error:Cannot read properties of null (reading"...") on my update query's.

It still traying to run my update query's,

I do not understand way retool is returning error on update query's when I haven't done anything to trigger a update yet.

-Thore

If you examine the state of the update query, do you see anything that triggers it? There might be a (convoluted) path that is causing it to run, including a trigger somewhere that runs when the app opens (via a success event, perhaps).

I think you want to make use of the Only run when field
image
for the value, you only want the this event to run when the variable js is complaining about is not null. so something like: {{ dropdown.selectedItem?.value != null && dropdown.selectedItem.value.length > 0 }}. by putting this in the Only run when area you're saying:

IF all of the following are true

  • dropdown.selectedItem exists
  • AND
  • dropdown.selectedItem.value is not null
  • AND
  • dropdown.selectedItem.value is not empty (empty string and empty array)

THEN run the event
ELSE skip this event

Hi

It looks like it did not work, is this a bug in retool or is it me that is doing something wrong?

In added the following on the "Update_status" query:
image
and
image

In added the following on the "Get_status" query:
image
and
image

-Thore

according to the error, somewhere in Update_Status you reference StatusId. Wherever you're using this in the Update_Status query it'll probably look like Get_Status.data.StatusId or something similar, try changing this to Get_Status.data?.StatusId and myVariable.value?.StatusId (@preshetin explained the reason for this above, but if you need more details or something just ask)

I had to guess with the 'Get_Status' name from the error message so that may be WAY wrong, just so you know before you copy/pasta it :smile:

edit: let me know if Update_Status doesn't reference StatusId at all (I may have read the call stack trace backwards :upside_down_face:

Hi

  1. I have a list of items in a table where user can select a row

  2. I have a form with data source "{{list.selectedRows[0]}}"

  3. in the form i have a dropdown that is Null from start
    image

  4. The dropdown is mapped with "Get_Status" query
    image
    and
    image

  5. Dropdown list has:
    image
    That triggers the update query when change.
    image

6.Update_Status query:
image
:frowning:
image

7.Adding "?": line is green :slight_smile:
image

I will update my update query's with "?" and I will assume this will work.

if status.selectedItem is 'null' or 'undefined' then {{status.selectedItem?.StatusId}} evalutes to 'null'. if the field that starts w 'fIdSpirStat' is not nullable and must be a string or something you can use {{ status.selectedItem? "my fallback value" : status.selectedItem.StatusId }}

Hi

As this is only when you start the App that I was getting the errors.
It looks like the use of "?" removed all my errors.

image

So I have solved my issue even if I don't understand that this was a issue at the first place (new beginner) as no user as trigger the update query to run yet.

1 Like