Skip to main content
Solved

Problem with fetching fields from table


i started an app and try to show table fields in my app
i used a code from guides as axemple, but when i request fields by their names it shows as undefined, but field record.id is displayed ok
i have table with wields Title, Price etc, but only record.id have value in app, but in table all fields have value
my code

1import {
2 initializeBlock,
3 useBase,
4 useRecords,
5} from '@airtable/blocks/ui';
6import React from 'react';
7
8function HelloWorldApp() {
9 // YOUR CODE GOES HERE
10 const base = useBase();
11 const table = base.getTableByName('events');
12 const records = useRecords(table);
13
14 const events = records.map(record => {
15 return (
16
17 {record.Price || 'not named record'}
18
19 );
20 });
21
22 return (
23
{events}
24 );
25}
26
27initializeBlock(() => );
28

Best answer by Kamille_Parks11

Field values are not a property of the record. You have to fetch them using record.getCellValue(name or ID of the field). Airtable Blocks SDK

View original
Did this topic help you find an answer to your question?

4 replies

Kamille_Parks11
Forum|alt.badge.img+27

Field values are not a property of the record. You have to fetch them using record.getCellValue(name or ID of the field). Airtable Blocks SDK


Forum|alt.badge.img+3
  • Participating Frequently
  • 59 replies
  • July 22, 2021

I don’t know what you use for development but if I may suggest VSCode with Typescript as that would have highlighted the error for you by placing a red squiggly under e.g. record.Price. Also you would have discovered the getCellValue method suggested by Kamille when you typed a dot after record.

Better tools save you a ton of time :slightly_smiling_face:


  • Author
  • New Participant
  • 1 reply
  • July 22, 2021

thanks, it works

strange, that in manual there is similar example with record.name, which is declared as working


kuovonne
Forum|alt.badge.img+29
  • Brainy
  • 6009 replies
  • July 22, 2021
vei_tsi wrote:

thanks, it works

strange, that in manual there is similar example with record.name, which is declared as working


Both the id and name are public properties of a record, as described in the documentation.


Reply