As an administrator, you may frequently encounter scenarios where you need to duplicate existing transactions—such as creating repeat invoices for loyal customers, replicating purchase orders, or preparing test data in your sandbox. Doing this manually can be time-consuming and error prone. Fortunately, SuiteScript 2.1 offers a solution: the record.copy.promise method.
This method allows you to asynchronously duplicate a record—such as a Sales Order, Invoice, or other supported transaction—while preserving all data from the source record. This approach is efficient, reduces manual effort, and ensures data consistency across your business processes.
Here’s the approach:
- Identify the Record to Copy:Determine the internal ID of the transaction you want to duplicate. This ensures the correct record is copied.
- Use record.copy.promise to Duplicate the Record:This method creates a new instance of the original transaction while preserving its data. It also supports asynchronous execution, so your script won’t block other operations.
- Modify Fields if Needed:Once copied, you can update any fields on the new transaction. Common updates include adding a memo, changing the customer, or adjusting item quantities.
- Save the New Record:After making modifications, save the new transaction to create it in the system. Always capture the new record’s internal ID for tracking and reference.
- Log and Handle Errors:Log the new record ID for auditing purposes and wrap your logic in error handling to manage unexpected issues during copying or saving.
Benefits of This Approach:
- Time-Saving: Quickly duplicate complex transactions without manually recreating them.
- Flexible: Modify only what’s necessary while keeping all other data intact.
- Reliable: Asynchronous handling ensures scripts run smoothly without blocking.
- Trackable: Logging and error handling help maintain control over automated processes.
By following this approach, admins can streamline transaction duplication, reduce errors, and improve operational efficiency.
For more details, you may check New to NetSuite | N/record: record.copy.promise(options) Method article and its sample script to understand usage and best practices.
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!