Hi!
I wanted to show a lookup field as <RecordCardList />
, but I can’t access the original field. I’m only getting the recordId
and fieldId
, not the tableId
(in field.options
).
Can someone help me with that?
Thanks!
Hi!
I wanted to show a lookup field as <RecordCardList />
, but I can’t access the original field. I’m only getting the recordId
and fieldId
, not the tableId
(in field.options
).
Can someone help me with that?
Thanks!
Best answer by Emma_Yeap
Hi Ivan,
Not sure I understand your question - are you saying that you have a lookup field (set up with a linked record field and a field in another table), and you want to retrieve the field that is being looked up in the other table?
How does this relate to using RecordCardList
, could you elaborate? (You can simply use <RecordCardList records={records} fields={[lookupField]} />
after getting the records in the table with useRecords(table)
)
I’m only getting the
recordId
andfieldId
, not thetableId
(infield.options
).
The screenshotted options you have contain recordLinkFieldId
(the MULTIPLE_RECORD_LINKS
field the lookup is referencing) and fieldIdInLinkedTable
(the field being looked up in the other table, via the linked records) - neither is a recordId
. (Tip: You can tell by the 3 letter prefix in the id. fld
is a field)
You can find the linked table id in the options of the MULTIPLE_RECORD_LINKS
field:
const base = useBase()
const table = ... // the table the lookupField came from
const lookupField = ... // the field you already have
const linkedRecordsField = table.getFieldById(lookupField.options.recordLinkFieldId);
console.log('Linked table ID', linkedRecordsField.options.linkedTableId);
// retrieve the linked table
const linkedTable = base.getTableById(linkedRecordsField.options.linkedTableId);
const originalField = linkedTable.getFieldById(lookupField.options.fieldIdInLinkedTable);
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.