Back to Blogs
NetSuite Diaries

Unlock SuiteScript Efficiency: Save Governance Points with Parent-Child Records

Jona Obrador
September 6, 2024
2
minutes to read

Background

SuiteScript governance limits can often constrain our ability to develop efficient features, especially when dealing with large datasets. In this article, we explore how leveraging parent-child record relationships can help overcome these limits and optimize SuiteScript performance.

Scenario: Syncing Messages on a Click

Imagine a company that needs to integrate customer communications from an external application into NetSuite. To simplify this process, a custom "Sync Messages" button is added to the customer record. Clicking this button triggers a SuiteScript that downloads and saves the messages within NetSuite.

Initial Solution Design

1. Create Custom Record Type

  • Name: Message
  • Fields: F

2. Implement Button and Scripts

  • Add a custom button using a user-event script.
  • Attach a client script to handle message retrieval and saving of each message.

Identified Issue

The initial design requires creating and saving each message individually, consuming 6 governance units per message (2 units for record.create() and 4 units for record.save()). With 100 messages, this amounts to 600 units, which is not scalable.

Optimized Approach

1. Use Parent-Child Relationships

Mark the customer record as the parent and message records as children.

custom-record-record-parent
Enable editing of child records directly from the parent record.
custom-record-allow-children

2. Efficient Data Handling

  • Replace multiple record operations with a single record load and save operation.
  • Use sublist functionality to insert and update messages in bulk.

message-script

Final Output

By leveraging parent-child record relationships and efficient data handling techniques in SuiteScript, this optimized approach drastically reduces governance usage, allowing you to process large volumes of data with minimal performance impact. This solution not only conserves governance points but also simplifies the management of customer communications within NetSuite, making your operations more scalable and efficient.

To explore the full SuiteScript code details discussed in this article, visit Jona's GitHub repository.

Meet the Author

jona-obrador-author

Jona has over a decade of experience in SuiteCloud Development on the NetSuite platform. She specializes in implementing advanced solutions and has led teams in creating high-quality software. Jona holds multiple certifications and has been recognized with awards like the Summit Award and Quality Champion Award.