ANS-1509 · SUITESCRIPT DEVELOPMENT
How to Access the Custom Form ID in a NetSuite beforeLoad Script (SuiteScript 1.0)
This article outlines the behavior of SuiteScript 1.0 functions for retrieving the custom form ID within a beforeLoad user event script, noting common execution challenges.
Short answer
To reliably retrieve the customform field value in a SuiteScript 1.0 beforeLoad user event script, use nlapiGetNewRecord().getFieldValue('customform'). The nlapiGetFieldValue('customform') function may fail in certain execution contexts, such as when printing records.
Scenario
Developers working with NetSuite SuiteScript 1.0 user event scripts may encounter difficulties when attempting to retrieve the customform field value within a beforeLoad event. Standard methods for field retrieval can be inconsistent, leading to script failures in specific execution scenarios, such as when generating printable versions of records.
Solution
When developing SuiteScript 1.0 user event scripts, it is crucial to select the appropriate function for accessing the customform field during the beforeLoad event. While SuiteScript 2.x is the current recommended standard, for existing SuiteScript 1.0 implementations, the following approach addresses common retrieval issues:
Avoid using nlapiGetFieldValue('customform') directly, as this function may not consistently return the customform value in all execution contexts. For instance, attempts to retrieve the value during print operations may result in failure.
Instead, utilize the nlapiGetNewRecord().getFieldValue('customform') function. This method has been observed to reliably retrieve the customform field value across various execution types within a SuiteScript 1.0 beforeLoad script.
// Example of unreliable method in SuiteScript 1.0 beforeLoad// var customFormId = nlapiGetFieldValue('customform'); // May fail in some contexts// Example of reliable method in SuiteScript 1.0 beforeLoadvar customFormId = nlapiGetNewRecord().getFieldValue('customform');Expert NetSuite Support
Need help with this NetSuite issue?
SuiteScript Development consulting and configuration support
