Record Transformation Method in SuiteScript 2.x

The record transformation method allows you to convert records between types, streamlining order processing and invoice creation.

·3 min read·1 views·View Oracle Docs

The record transformation method in SuiteScript 2.x enables developers to transform one type of record into another, leveraging existing record data. This capability is particularly useful for automating processes such as order processing and the creation of item fulfillment transactions and invoices.

How Does the Record Transformation Method Work?

Transforming a record requires specifying certain parameters. The method provides both synchronous and promise-based (asynchronous) variants. The promise version can be particularly beneficial in client scripts where asynchronous processing is preferred.

Method Description

  • Functionality: The method transforms a record of one type into another using the data from an existing record.
  • Returns: A new record object.

Governance

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

Supported Script Types

This method can be utilized in both client and server scripts. For a detailed overview of SuiteScript 2.x script types, refer to the SuiteScript 2.x Script Types documentation.

Parameters

The method accepts an options parameter which is a JavaScript object containing the following fields:

Field NameTypeRequired / OptionalDescription
fromTypestringRequiredThe record type of the existing record instance being transformed. This value sets the Record.type property for the record and is read-only.
fromIdnumberRequiredThe internal ID of the existing record instance being transformed.
toTypestringRequiredThe record type of the new record that will be returned after the transformation.
isDynamicbooleanOptionalDetermines if the new record is created in dynamic mode. Defaults to false.
defaultValuesObjectOptionalName-value pairs for default values of fields in the new record.

Error Handling

You may encounter the following error:

  • SSS_MISSING_REQD_ARGUMENT: Thrown if a required argument is missing or undefined.

Example Syntax

Here’s how you might implement the transformation method:

suitescript
1var objRecord = record.transform({
2 fromType: record.Type.CUSTOMER,
3 fromId: 107,
4 toType: record.Type.SALES_ORDER,
5 isDynamic: true,
6});
suitescript
1record.transform({
2 fromType: 'salesorder',
3 fromId: 6,
4 toType: 'invoice',
5 defaultValues: { billdate: '01/01/2019' }
6});

Supported Transformation Types

The record transformation method supports a variety of transformation types. Here are some noteworthy examples:

  • Assembly Build: converts to Assembly Unbuild.
  • Cash Sale: can transform into Credit Memo, Invoice, and more.
  • Vendor Bill: can convert into Vendor Credit or Vendor Payment.

For a full list of supported transformations and their corresponding record types, check the documentation.

Conclusion

Understanding the nuances of record transformation in SuiteScript 2.x is crucial for effectively utilizing NetSuite's automation capabilities. This knowledge not only aids in improving efficiency but also enhances the accuracy of record management within your applications.

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

Frequently Asked Questions (4)

Can the record transformation method be used in both client and server scripts in SuiteScript 2.x?
Yes, the record transformation method is supported in both client and server scripts in SuiteScript 2.x.
What happens if a required parameter is missing when using the record transformation method?
If a required parameter is missing, the method will throw the error 'SSS_MISSING_REQD_ARGUMENT'.
What are the governance units associated with transforming transaction records using SuiteScript 2.x?
Transforming transaction records consumes 10 governance units in SuiteScript 2.x.
Is it possible to transform a Cash Sale into an Invoice using the record transformation method?
Yes, a Cash Sale can be transformed into an Invoice using the record transformation method.
Source: Syntax 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 Integration

View all Integration articles →