# Getting a \`Cannot read properties of null (reading 'length')\` error when using \`kintone.app.getFieldElements()\`?

**URL:** https://forum.kintone.dev/t/getting-a-cannot-read-properties-of-null-reading-length-error-when-using-kintone-app-getfieldelements/632
**Category:** Tips & Tricks
**Tags:** getfieldelements, tips
**Created:** [October 12, 2022, 2:51am UTC](https://forum.kintone.dev/t/getting-a-cannot-read-properties-of-null-reading-length-error-when-using-kintone-app-getfieldelements/632 "2022-10-12T02:51:45Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Genji](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.kintone.dev/genji/32/646_2.png) [@Genji](https://forum.kintone.dev/u/Genji)
#### Post date: [October 12, 2022, 2:51am UTC](https://forum.kintone.dev/t/getting-a-cannot-read-properties-of-null-reading-length-error-when-using-kintone-app-getfieldelements/632/1 "2022-10-12T02:51:45Z")

</div>

## What is the `kintone.app.getFieldElements()`?

[`kintone.app.getFieldElements()`](https://kintone.dev/en/docs/kintone/js-api/apps/get-record-list-field-elements/) is Kintone's JavaScript API that allows you to retrieves a specified field element of fields in the record list as an array.

### Function

`kintone.app.getFieldElements(fieldCode)`

### Parameters

Swap `fieldCode` with the field code of the field you want to retrieve.

### Response

Either an array of field elements or `null` will return.

`null` is returned when:

- Current page is not a [Record List view](https://get.kintone.help/k/en/id/040614.html#view_whatsview_2010).
- Current Record List view does not have the specified field.

An empty array will be returned if there are no records.

## Uncaught TypeError: Cannot read properties of null (reading 'length') error

The `Cannot read properties of null (reading 'length')` error is a JavaScript error that occurs when you try to access a property of a `null` value.

To resolve this error, you must check if the value is `null` before accessing its properties.

## `Cannot read properties of null (reading 'length')` error when using `kintone.app.getFieldElements()`

Since `kintone.app.getFieldElements()` returns `null` in several scenarios (listed in **Response** section), include a check to verify that you are getting an array before proceeding.

Possible causes for the `Cannot read properties of null (reading 'length')` error are:

1. The specified field code is incorrect.
2. The current page is not a Record List view.
3. The current page does not include the specified field.
