ANS-0960 · WEB SERVICES & INTEGRATIONS
How to Manage NetSuite SuiteTalk Field Visibility on Custom Forms
Understand how to ensure fields are accessible via web services by adjusting form configurations or using SuiteScript.
Short answer
To set values for fields via SuiteTalk web services, they must be present on the selected NetSuite form. If a field is not visible, specify an alternate custom form for the web service call, or use a SuiteScript 2.x User Event script to dynamically adjust the field's display type during the `beforeLoad` event for web service contexts.
Scenario
Users attempting to interact with NetSuite records via SuiteTalk web services may encounter issues when trying to set values for fields that are not visible or enabled on the default or specified custom form. This often occurs with fields that are typically hidden or disabled in the NetSuite UI but require manipulation through external integrations.
Solution
Fields must be present on the form used by the web services call to allow values to be set. There are two primary approaches to address this:
Specify an Alternate Form: When making a SuiteTalk web services call, explicitly specify a custom form where the required field is present and visible. This ensures the field is available for interaction.
Use a User Event Script: For scenarios where a field needs to be dynamically made visible or editable, especially for web service contexts, a User Event script (SuiteScript 2.x) can be deployed. This script will adjust the field's display type during the
beforeLoadevent.It is important to note that while form display properties can be manipulated in
beforeLoadfor both new and existing records, direct data manipulation (setting field values) for *existing* records is generally not possible within thebeforeLoadcontext in SuiteScript 2.x. However, making a field visible allows subsequent operations (e.g., inbeforeSubmitorafterSubmit, or by the web service itself) to interact with it.Below is an example of a SuiteScript 2.x User Event script that makes a specified field visible when the execution context is
webservices:
javascript
/**
* @NApiVersion 2.x
* @NScriptType UserEventScript
*/
define(['N/runtime', 'N/ui/serverWidget'], function(runtime, serverWidget) {
function beforeLoad(context) {
if (context.type === context.UserEventType.CREATE || context.type === context.UserEventType.EDIT) {
if (runtime.executionContext === runtime.ContextType.WEBSERVICES) {
var form = context.form;
var field = form.getField({ id: 'field_id' }); // Replace 'field_id' with the actual field ID
if (field) {
field.updateDisplayType({
displayType: serverWidget.FieldDisplayType.NORMAL
});
}
}
}
}
return {
beforeLoad: beforeLoad
};
});In this script:
N/runtimeandN/ui/serverWidgetmodules are loaded for context and form manipulation.- The
beforeLoadfunction is triggered before a record is loaded. runtime.executionContext === runtime.ContextType.WEBSERVICESchecks if the script is running due to a web services call.form.getField({ id: 'field_id' })retrieves the field object.field.updateDisplayType({ displayType: serverWidget.FieldDisplayType.NORMAL })sets the field's display type to normal, making it visible and editable.- The
context.typecheck (CREATEorEDIT) is added for robustness, asbeforeLoadcan also fire forVIEWevents where display changes might not be relevant for web services.
Expert NetSuite Support
Need help with this NetSuite issue?
Web Services & Integrations consulting and configuration support
