Help

Re: TypeError: line 40 Create Records from multi select

551 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Super_Soils
4 - Data Explorer
4 - Data Explorer

The entire error is;

TypeError: Cannot read property ‘length’ of undefined at main on line 40.

Line 40 reads;

let recToCreate = s.delivField.options?.choices.length;

OK, so “s” was defined at the top of the script as input config, and “delivField” is defined as an input field of “s” So AFAICS this should NOT be undefined. Any ideas? Anyone else used this script?

1 Reply 1

But what is s? Is it a record?

  • If you’re creating records from all choices defined in the field’s configuration settings, then you don’t need s no matter what it is. The code would just be delivField.options.choices.length
  • If you’re creating records from each of a particular record’s selected choices, and s is that record, then you’re using the wrong syntax. To get a record’s cell value, you need s.getCellValue(delivField).length < That may return an error for you if the field is blank (meaning there is no array, not an empty array).
    • If s is a record, its saying undefined because delivField is not a property of the record. Records only have .id and .name as properties.