Get all Field names from a NetSuite custom record

In SuiteScripts2 there are several ways of get all field names from a custom record.

How to get them depends on if the record is loaded in memory or not.

If the record is loaded there is a method getFields() (N/record) to get an array of field names.


But if the record is not loaded and there are no instances of that record, there is an old trick to

create the record, and run the getFields() method on the newly created record, never save the record and return the array.

This method is extremely slow and you can get in trouble with permissions.


A better method (10 times faster) is to  use the N/query module and combining results from the tables CustomRecordType and CustomField:

See more blog posts