Record Transformation Method in SuiteScript 2.x

The record transformation method in SuiteScript 2.x enables developers to convert one record type into another efficiently, optimizing workflows.

·3 min read·View Oracle Docs

The record transformation method allows developers to convert one record type into another by utilizing data from an existing record. This function is particularly useful for automating tasks such as order processing, creation of item fulfillment transactions, and generating invoices from orders.

What Are the Supported Transformation Types?

This method supports various transformations. Below are examples of transformations you can perform:

Original Record NameOriginal Record TypeTransformed Record NameTransformed Record Type
Assembly BuildassemblybuildAssembly Unbuildassemblyunbuild
Cash SalecashsaleCredit Memocreditmemo
Customer PaymentcustomerpaymentInvoiceinvoice
Vendor BillvendorbillVendor Paymentvendorpayment
Work OrderworkorderAssembly Buildassemblybuild

Note: Be aware that some transformations like creating an Assembly Build for an Outsourcing Work Order are not supported through SuiteScript.

How to Use the Method

Parameters

To use the method, you will pass an options parameter, which is a JavaScript object that includes the following:

ParameterTypeRequired / OptionalDescription
fromTypestringrequiredSpecifies the record type of the existing record you wish to transform.
fromIdnumberrequiredIndicates the internal ID of the existing record to be transformed.
toTypestringrequiredDefines the record type of the record that will be returned once the transformation is complete.
isDynamicbooleanoptionalSet to true for dynamic mode or false for standard mode (default is false).
defaultValuesObjectoptionalAllows you to specify default field values for the new record. Defaults to null.

Example Code

Here are some code examples that demonstrate how to use the record.transform 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: {
6 billdate: '01/01/2019'} });

Error Handling

Be prepared to catch errors using the following code:

  • SSS_MISSING_REQD_ARGUMENT: This error is thrown if a required argument is missing or undefined.

Best Practices

  • Before performing transformations, always verify that the original record type and values are correct to avoid runtime errors.
  • Utilize the dynamic mode cautiously, ensuring that values are set in the same order as in the UI for accurate results.

Who This Affects

This feature is particularly relevant for:

  • Developers: Automating workflows and improving script efficiency.
  • Administrators: Managing and overseeing record transformation processes and related customizations.

Key Takeaways

  • The record.transform method streamlines the process of transforming records such as sales orders into invoices.
  • Supports various record types and provides options for default values and mode configurations.
  • Ensure proper error handling to manage required parameters effectively.

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

Frequently Asked Questions (4)

What permissions are required to use the record transformation method in SuiteScript 2.x?
The article does not specify the exact permissions needed, so you should review your role permissions or consult official NetSuite documentation for details.
Can I perform a record transformation from an Outsourcing Work Order to an Assembly Build using SuiteScript?
No, SuiteScript does not support transforming an Outsourcing Work Order into an Assembly Build.
How should errors be handled when using the record transformation method in SuiteScript 2.x?
You should handle errors by being prepared to catch specific exceptions such as 'SSS_MISSING_REQD_ARGUMENT' if a required argument is missing or undefined.
Is dynamic mode mandatory when using the record transformation method?
No, dynamic mode is not mandatory. You can set 'isDynamic' to 'true' for dynamic mode or 'false' for standard mode, with standard mode being the default.
Source: Parameters 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 →