As a NetSuite Administrator, you may occasionally need to inspect the metadata of fields on a Customer record while troubleshooting customizations, validating configurations, or verifying field properties. Rather than checking each field manually through the UI, you can use the getField() method to retrieve a Field object and inspect its metadata, including the field's internal ID, label, and data type.
SuiteScript Example
/**
* @NApiVersion 2 .1
* @NScriptType ScheduledScript
*/
define(['N/record', 'N/log'], (record, log) => {
function execute(context) {
// Load an existing Customer record.
// Replace 123 with a valid Customer internal ID.
var customerRec = record.load({
type: record.Type.CUSTOMER,
id: 123
});
// List of Customer fields to inspect
var fieldsToCheck = [
'entityid', // Customer Name/ID
'email', // Email Address
'phone', // Phone Number
'comments' // Comments
];
// Loop through each field
fieldsToCheck.forEach(function(fieldId) {
// Retrieve the Field object
var field = customerRec.getField({
fieldId: fieldId
});
// Log the field's metadata
log.debug({
title: 'Customer Field Metadata',
details:
'ID: ' + field.id +
', Label: ' + field.label +
', Type: ' + field.type
});
});
}
return {
execute: execute
};
});
This Scheduled Script loads a Customer record and retrieves several commonly used fields using the getField() method. Each call returns a Field object, which contains metadata about the field rather than its value.
The script then logs the following properties:
- Field.id – Returns the field's internal ID (for example, entityid or email).
- Field.label – Returns the label displayed on the form.
- Field.type – Returns the field's data type, such as text, email, or textarea.
DISCLAIMER: The sample code described herein is provided on an "as is" basis, without warranty of any kind, to the fullest extent permitted by law. Oracle + NetSuite Inc. does not warrant or guarantee the individual success developers may have in implementing the sample code on their development platforms or in using their own Web server configurations.
Oracle + NetSuite Inc. does not warrant, guarantee or make any representations regarding the use, results of use, accuracy, timeliness or completeness of any data or information relating to the sample code. Oracle + NetSuite Inc. disclaims all warranties, express or implied, and in particular, disclaims all warranties of merchantability, fitness for a particular purpose, and warranties related to the code, or any service or software related thereto.
Oracle + NetSuite Inc. shall not be liable for any direct, indirect or consequential damages or costs of any type arising out of any action taken by you or others related to the sample code.
To know more about deploying SuiteScript, check these New to NetSuite Articles.
Do you have another way on how to automate your transactions using SuiteScript? Feel free to share them here!