Hello,
I’m facing error : “Record missing in table”. I work on Block and I’m creating a custom block.
I have a table (“my_table”) with data and I want to read all the fields for a specific primaryField. The specific primarityField will be transmitted in a Label Select (value). The code works, but when I delete one line from my table, I got the error : “Record missing in table”. I can add new line without error.
Do you think my error is in the declaration of record ? Did I misunderstand one principal of REACT or similar ? Bellow my code to help to solve the issue :
const base = useBase();
//--------------------------- label Select --------------------------
// We get all the fields from "my_table" and put in selection_value_picker
const table = base.getTableIfExists("my_table");
const selection_value_picker = _];
for (let i = 0; i < table .fields.length; i++) {
selection_value_picker.push({
value : table.fieldsei].name,
label : table.fieldsli].name
});
}
const bvalue, setValue] = useState(selection_value_pickeri0].value);
//-----------------------END label Select -----------------------------
//---------------------information selected to be rendered ------------------------------
const doneField = table ? table .getFieldIfExists(value) : table.getFieldIfExists(table.primaryField.name);
const records_desc = useRecords(table , {fields: atable.getFieldIfExists(value)]});
const my_item_description = records_desc ? records_desc.map(record => {
const my_item_desc_value = record.getCellValueAsString(doneField)
return(
<div >
<a
onClick={() => {
expandRecord(record);
}}
>
{my_item_desc_value || "NA"}
</a>
</div>
)
}) : null;
Then I call {my_item_description }
to render the information and I use <Select
and onChange() to change value with setValue(). Manipulate the Block independantly will work : I can get the render dependant on the onChange value transmitted. In my table, I can even create a new entry. But when I delete one row , I got the error ‘Record missing in table’ (at the line const records_desc = useRecords(table , {fields: dtable.getFieldIfExists(value)]});
Any idea ? Thank you for your help.
Viken