Record Transformation Method for SuiteScript Automation

Utilize the record transformation method in SuiteScript to automate order processing, invoice creation, and more.

·3 min read·View Oracle Docs

TL;DR Opening

The record transformation method in SuiteScript allows for the conversion of one record type into another, facilitating automation in order processing, invoice creation, and item fulfillment transactions. This method is essential for integrating workflows within NetSuite effectively.

Understanding Record Transformation

The record.transform(options) method provides developers a way to convert records from one type to another. This capability is particularly useful in automating various tasks such as creating invoices or item fulfillment transactions based on existing order records.

For example, if you want to create a sales order from a customer record or generate an invoice from an existing sales order, this method simplifies the process significantly.

Method Description

record.transform() is used as follows:

  • Purpose: This method transforms an existing record type into a new record type by using data from the original record.
  • Supported Transformations: There are numerous supported transformations, including creating invoices from sales orders and generating cash refunds from cash sales.

Returns

This method returns an instance of a record.Record object, which represents the transformed record.

Supported Script Types

The transformation method can be utilized in both client and server scripts, allowing flexibility in how scripts can be executed within the NetSuite environment.

Governance

Utilization of this method incurs governance limits based on the type of record being transformed:

  • Transaction Records: 10 units
  • Custom Records: 2 units
  • All Other Record Types: 5 units

Parameters

The options parameter is a JavaScript object that comprises:

ParameterTypeRequired/OptionalDescription
fromTypestringrequiredThe record type of the existing record instance being transformed.
fromIdnumberrequiredThe internal ID of the existing record instance being transformed.
toTypestringrequiredThe record type of the resulting record after transformation.
isDynamicbooleanoptionalDetermines if the new record is created in dynamic mode. Default is false.
defaultValuesObjectoptionalName-value pairs for default values of fields in the new record.

Errors

If an error occurs, the typical error thrown is:

  • SSS_MISSING_REQD_ARGUMENT: This indicates that a required argument is missing or undefined.

Syntax

Here are code samples demonstrating the syntax for transforming records:

Example 1 - Transforming a Customer to Sales Order

suitescript
1var objRecord = record.transform({
2 fromType: record.Type.CUSTOMER,
3 fromId: 107,
4 toType: record.Type.SALES_ORDER,
5 isDynamic: true,
6});

Example 2 - Transforming a Sales Order to Invoice

suitescript
1record.transform({
2 fromType:'salesorder',
3 fromId: 6,
4 toType: 'invoice',
5 defaultValues: {
6 billdate: '01/01/2019'}
7});

Supported Transformation Types

The following table lists the supported record transformations:

Original Record NameOriginal Record TypeTransformed Record NameTransformed Record Type
Assembly BuildassemblybuildAssembly Unbuildassemblyunbuild
Cash SalecashsaleCredit Memocreditmemo
CustomercustomerCustomer Paymentcustomerpayment
Sales OrdersalesorderInvoiceinvoice
Purchase OrderpurchaseorderItem Receiptitemreceipt

Who This Affects

  • Developers using SuiteScript for record management.
  • Administrators looking to automate workflows efficiently.

Key Takeaways

  • The record.transform() method automates converting record types.
  • It supports multiple record transformations, streamlining business processes.
  • Understanding parameter governance is crucial to avoid performance issues.

Source: This article is based on Oracle's official NetSuite documentation.

Frequently Asked Questions (4)

What are the supported script types for the record transformation method in SuiteScript?
The record transformation method can be utilized in both client and server scripts, allowing for flexible execution of scripts within the NetSuite environment.
What governance limits apply when using the record transformation method?
Governance limits depend on the type of record being transformed: 10 units for transaction records, 2 units for custom records, and 5 units for all other record types.
How does the `record.transform()` method handle missing arguments?
If a required argument is missing or undefined, the method throws an `SSS_MISSING_REQD_ARGUMENT` error, indicating that a necessary argument was not provided.
Can `record.transform()` create a sales order from a customer record?
Yes, `record.transform()` can be used to create a sales order from a customer record, as demonstrated in the provided code example in the article.
Source: Errors Oracle NetSuite Help Center. This article was generated from official Oracle documentation and enriched with additional context and best practices.

Was this article helpful?

More in General

View all General articles →