Record Transformation Method for SuiteScript Automation
Utilize the record transformation method in SuiteScript to automate order processing, invoice creation, and more.
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:
| Parameter | Type | Required/Optional | Description |
|---|---|---|---|
fromType | string | required | The record type of the existing record instance being transformed. |
fromId | number | required | The internal ID of the existing record instance being transformed. |
toType | string | required | The record type of the resulting record after transformation. |
isDynamic | boolean | optional | Determines if the new record is created in dynamic mode. Default is false. |
defaultValues | Object | optional | Name-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
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
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 Name | Original Record Type | Transformed Record Name | Transformed Record Type |
|---|---|---|---|
| Assembly Build | assemblybuild | Assembly Unbuild | assemblyunbuild |
| Cash Sale | cashsale | Credit Memo | creditmemo |
| Customer | customer | Customer Payment | customerpayment |
| Sales Order | salesorder | Invoice | invoice |
| Purchase Order | purchaseorder | Item Receipt | itemreceipt |
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.
Frequently Asked Questions (4)
What are the supported script types for the record transformation method in SuiteScript?
What governance limits apply when using the record transformation method?
How does the `record.transform()` method handle missing arguments?
Can `record.transform()` create a sales order from a customer record?
Was this article helpful?
More in SuiteScript
- Common SuiteScript Errors and Solutions for NetSuite
Common NetSuite script errors include INVALID_SCRIPT_DEPLOYMENT_ID and SSS_AUTHORIZATION_HEADER_NOT_ALLOWED. Learn effective solutions.
- Set Sublist Field Values in SuiteScript 2.x for Record Management
Set sublist field values in SuiteScript 2.x for effective record management using standard and dynamic modes.
- Setting Field Values in SuiteScript for Effective Record
Learn to set field values in SuiteScript effectively, troubleshooting common errors and understanding data types.
- SuiteScript 2.1 Enhancements and API Updates in NetSuite
SuiteScript 2.1 enables execution of 2.0 scripts and supports PATCH method for enhanced API capabilities.
Advertising
Reach SuiteScript Professionals
Put your product in front of NetSuite experts who work with SuiteScript every day.
Sponsor This Category