ANS-0432 · SUITESCRIPT DEVELOPMENT

How to Programmatically Check for ‘Copy’ Operation in NetSuite UI

Understand the recommended SuiteScript approach for identifying when a record is being copied within the NetSuite user interface.

Short answer

The most robust method to check for a 'copy' operation specifically within the NetSuite user interface context involves evaluating both the operation type and the execution context. This ensures the script accurately identifies user-initiated copy actions, avoiding reliance on potentially inconsistent URL parameters. Use `if (type == 'copy' && runtime.ContextType.USER_INTERFACE)`.

Scenario

When developing SuiteScripts, it is often necessary to execute specific logic only when a record is being copied by a user directly within the NetSuite interface. Relying on URL parameters to detect a copy operation can be unreliable, as these parameters may not always be present or consistent across different NetSuite environments or versions. A more robust method is required to accurately identify this specific user action.

Solution

The recommended approach for programmatically checking if a record is being copied within the NetSuite user interface involves evaluating both the operation type and the execution context. This method is more reliable than parsing URL parameters, which can be inconsistent.

To implement this, use the following conditional statement in your SuiteScript:

if (type == 'copy' && runtime.ContextType.USER_INTERFACE)

This condition ensures that the script's logic only executes when the record operation is specifically a 'copy' and the script is running within the user interface context.

Expert NetSuite Support

Need help with this NetSuite issue?

SuiteScript Development consulting and configuration support

Talk to a consultant