table.selectedRow evaluating to null - but the record is displayed in the table

Hi All,

I have a table that is displaying data joined from 2 APIs. There are also some custom columns that are displaying an icon based on the value in the table for that row.

I would like to use the value of fields for the selected row. This works for all rows, except one in my test case (the one row is different from the rest). In terms of the join - it's a left join and this row is the only row which doesn't have values in the right hand side of the join. However - it still has values in the table which I am trying to reference, so I would expect this to work.

Here is the table, displaying the 4 records:

The table is called table_relationship_contacts.

If I try and reference a value from the selected row, for example 'forename', it works for every row except row 3. When I look in the state table, all values for selectedRow when I have row 3 selected evaluate to null.

Example trying to reference the selected row:

{{table_relationship_contacts.selectedRow.forename}}

Any idea what I can do to check why row 3 values are evaluating to null when it is the selected row, but the other rows work? I would expect it to work given that I can see the values displayed in the table, and I am referencing these!

Thanks in advance for any help or pointers.

'bump' - is there any extra information I can provide that would be helpful to find what I'm doing incorrectly on this one?

Thanks!

Hey @MFinTech!

This definitely sounds odd. Would you mind sharing screenshots of how your table shows up in your debug tools? I'm particularly curious to see how selectedRow and data show up there, and if this is for the new table I'd be interested to see selectedSourceRow as well.

Would you also mind sharing what kind of SQL resource you're using?

Hi @Kabirdas!

Apologies for the delayed reply - I've been away.

I was just explaining as per the below (unfinished explanation) - but I have found the issue whilst writing out the issue again (a classic example of rubber ducking!).

Unfinished explanation:

*It is strange. All data in selectedRow for this selected row shows 'null'. But the table is populated with data in this row.*

*I have the problem row selected for this screenshot:*

*![image|690x314, 50%](upload://gd0lEUqGKmGTMdDAeHKDbgxBFLD.png)*

*And yet, in data the records display the correct values:*

*![image|690x286, 75%](upload://bY3bfimhvwb7XSeGm4zdI3JXi9A.png)*

AND then I spotted it:
My data source for the table was a join of 2 APIs, a left join. However, I had (accidentally) set the primary key of the table to something from the right side of the join (that therefore wasn't always populated). However - given this, I wouldn't expect the table to be populated with the record - especially if selectedRow is null.

Thanks for asking - as it helped me find the cause of my issue. But should this error also be captured?

Thanks for your help!

1 Like

That's a good callout!

There's some in-app documentation that indicates Primary Keys are used for row selection:

It looks like if you pick a Primary Key column with empty values it isn't prohibited but should throw the following warning:

But it's certainly true that not all the effects of having null values in the ID column are apparent. (I wasn't aware of this before you surfaced it either :sweat_smile: )