Custom Record

A custom record can be used to collect information specific to the needs of your business. For example, you may want to keep track of training courses your employees have taken. Since a record type specific for this purpose does not exist in NetSuite, you could create a custom record type, titled Employee Courses, specifically to store the training course data.

The NetSuite UI enables you to create custom record types and work with instances of those types. You cannot use SuiteScript to create a custom record type or make changes to an existing custom record type. However, you can use SuiteScript to interact with instances of an existing custom record type.

For example, suppose your system had a custom record type called Feature. Each instance of that record type would be a feature record. You could use SuiteScript to update an existing feature record, delete a feature record, or create a new feature record. However, you could not use SuiteScript to alter the Feature custom record type.

For help working with this record in the UI, see Creating Custom Record Types.

See the SuiteScript Records Browser for all internal IDs associated with this record, which includes a list of fields commonly available on instances of all custom records.

To interact with fields that were created for a specific record custom type, use the IDs for those fields. These IDs have a prefix of custrecord. For help finding these IDs, see Internal IDs for Standard and Custom Fields in Field Level Help Window.

Note:

For information about using the SuiteScript Records Browser, see Working with the SuiteScript Records Browser in the NetSuite Help Center.

For information about scripting with records in SuiteScript, see the following help topics:

Custom Record IDs

Each custom record has a unique ID. This value is shown in the ID field on the custom record. When creating or interacting with an instance of a custom record type, you must use this ID.

Every custom record ID is prefaced by customrecord. If the ID was entirely system generated, it ends with a number (for example, customrecord100). If the ID was customized when the record was created, the ID may be more descriptive. To view a list of all IDs, go to Customization > Lists, Records, & Fields > Record Types. The values are shown in the ID column.

The Record Types page with the ID column highlighted.

You can also see the ID on the record that represents the custom record type.

The Custom Record Type page with the ID field highlighted.

In SuiteScript 2.0, you use this value to set the Record.type or CurrentRecord.type field. Note that this guidance differs from the way you set this field if you are working with a standard NetSuite record type. When working with a standard record type, you set this field by using either the record.Type or CurrentRecord.type enum.

See the Code Sample for examples.

Supported Script Types

Custom records (instances of a custom record type) are scriptable in both client and server SuiteScript.

All three user events are supported: beforeLoad, beforeSubmit, and afterSubmit.

Supported Functions

Custom records are fully scriptable — they can be created, updated, copied, deleted, and searched using SuiteScript.

Code Sample

In SuiteScript 2.0, you use the N/record Module and N/currentRecord Module to interact with custom records, the same as you would with a standard record type. Note that you use the custom record type’s string ID when setting the Record.type field, as shown in the following example. For help finding this ID, see Custom Record IDs.

The following sample shows how to work with instances of a custom record type with the script ID customrecord_feature. This sample assumes that this custom record type has fields with the field IDs custrecord_priority and custrecord_risklevel.

          /**
 * @NApiVersion 2.x
 * @NScriptType UserEventScript
 */

define([ 'N/record' ], function(record) {
    function afterSubmit (context) {      
        // Use a string internal ID to identify the custom record type. 
        var rec = record.create({
            type: 'customrecord_feature',
            isDynamic : true
        });

        rec.setValue({
            fieldId: 'name',
            value: 'entry form redesign'
        });

        rec.setValue({
            fieldId: 'custrecord_priority',
            value: 1
        });

        rec.setValue({
            fieldId: 'custrecord_risklevel',
            value: 3
        });

        try {
            var callId = rec.save();
                log.debug('Call record created successfully', 'Id: ' + callId);
            } catch (e) {
                log.debug('sigh');
                log.error(e.name);
            }
        }
        return {
            afterSubmit: afterSubmit
        };
}); 

        

Related Topics

General Notices