ANS-0326 · SUITESCRIPT DEVELOPMENT

How to Prevent Child Records from Being Overwritten in NetSuite Custom Record Submissions

Understand the impact of script triggers and child record editing settings on custom record creation in NetSuite.

Short answer

To prevent child records from being overwritten during custom record submission, either create the child record in an `afterSubmit` script or ensure the child record's 'Allow Child Record Editing' setting is unchecked if using a `beforeSubmit` trigger. This prevents the system from interpreting the child record as null.

Scenario

When working with custom records in NetSuite, users may encounter situations where child records are not created or are unexpectedly overwritten during the submission of a parent record. This often occurs when a `beforeSubmit` script trigger is used for child record creation without specific configurations to manage their state.

Solution

To ensure child records are correctly created and not inadvertently overwritten during custom record submissions, consider one of the following approaches:

  1. Create Child Records in `afterSubmit`:

    The most robust method is to create the child record within an

afterSubmit

script. This ensures the parent record has been successfully saved before attempting to create or link child records.

  1. Configure Child Record Editing for `beforeSubmit`:

    If the script trigger must remain in

beforeSubmit

, the child record's configuration needs adjustment. Navigate to the custom record definition and ensure the '

Allow Child Record Editing

' feature is unchecked.If neither of these methods is employed, the

beforeSubmit

trigger may interpret the child record as being set to null, leading to it not being created or being overwritten.

Expert NetSuite Support

Need help with this NetSuite issue?

SuiteScript Development consulting and configuration support

Talk to a consultant