I would like to determine if a row has been selected and send a message if it hasn't.
I have developed some code as below which does not work.
const row = table1.selectedRow?.data;
console.log(table1.selectedRow);
if (!row || Object.keys(row).length === 0) {
utils.showNotification({
title: "No patient selected",
description: "Please select a patient from the table first.",
notificationType: "warning",
})} else {
modalFrame3.show();
return true;
}
Has anyone here got this figured out?
Mike
Summary
A warning-and-modal flow isn't working because the code checks table1.selectedRow?.data to determine whether a table row has been selected, but that expression never returns a value.
AI Response
In the current Table component, selectedRow returns the selected row's data object directly and is null/undefined when nothing is selected — there is no nested .data sub-property (that structure belonged to the classic Table component). Referencing table1.selectedRow?.data therefore always yields undefined, so the empty-selection branch never behaves as intended. Reference the row directly instead and test it for null, e.g. const row = table1.selectedRow; if (!row) { utils.showNotification({ title: 'No patient selected', description: 'Please select a patient from the table first.', notificationType: 'warning' }); } else { modalFrame3.show(); }. Confirm the exact shape by inspecting table1.selectedRow in the state/left panel while a row is and isn't selected.
Sources
Property 'selectedRow' doesn't work
Solved topic clarifying that the new Table component's selectedRow is referenced directly rather than through a nested property, which is the root cause here.
Table SelectedRow is not working
Solved report of selectedRow appearing not to work, with guidance on correctly accessing the selected row's values.
The Community Team is testing out a new automation. Let us know if it's helpful (or not) by leaving a
,
, or
. Or by marking this post as the "Solution"! Let us know if you have any feedback here. 