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.
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 Name | Original Record Type | Transformed Record Name | Transformed Record Type |
|---|---|---|---|
| Assembly Build | assemblybuild | Assembly Unbuild | assemblyunbuild |
| Cash Sale | cashsale | Credit Memo | creditmemo |
| Customer Payment | customerpayment | Invoice | invoice |
| Vendor Bill | vendorbill | Vendor Payment | vendorpayment |
| Work Order | workorder | Assembly Build | assemblybuild |
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:
| Parameter | Type | Required / Optional | Description |
|---|---|---|---|
fromType | string | required | Specifies the record type of the existing record you wish to transform. |
fromId | number | required | Indicates the internal ID of the existing record to be transformed. |
toType | string | required | Defines the record type of the record that will be returned once the transformation is complete. |
isDynamic | boolean | optional | Set to true for dynamic mode or false for standard mode (default is false). |
defaultValues | Object | optional | Allows 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:
1var objRecord = record.transform({2 fromType: record.Type.CUSTOMER,3 fromId: 107,4 toType: record.Type.SALES_ORDER,5 isDynamic: true,6});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.transformmethod 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.
Frequently Asked Questions (4)
What permissions are required to use the record transformation method in SuiteScript 2.x?
Can I perform a record transformation from an Outsourcing Work Order to an Assembly Build using SuiteScript?
How should errors be handled when using the record transformation method in SuiteScript 2.x?
Is dynamic mode mandatory when using the record transformation method?
Was this article helpful?
More in SuiteScript
- SuiteScript 2.1 Enhancements in NetSuite February Updates
SuiteScript 2.1 now supports async features and PATCH method. Discover the latest API and SuiteProcurement improvements.
- Scheduling Map/Reduce Script Deployments in NetSuite
Learn to schedule map/reduce script submissions, including one-time and recurring options in NetSuite.
- Binary File Support in N/https Module for SuiteScript
SuiteScript enhances capabilities with binary file support in the N/https module, allowing improved data handling in external communications.
- API Governance Units Calculation in NetSuite 2026.1
NetSuite 2026.1 introduces examples illustrating API governance unit calculations for both user event and scheduled scripts.
