SuiteScript 2.0 working with subrecords

SuiteScript 2.0 working with subrecords

In this netsuite training we as a netsuite solution provider come with Subrecords. Subrecords represent a way of storing data in NetSuite. Like records, subrecords are classified by type. Some common types of subrecord include address, inventory detail, and order schedule.

Each subrecord type has a different purpose and includes different fields. For example:

  • An address subrecord stores an address. It has fields such as city, state, and zip.
  • An order schedule subrecord represents a purchase schedule. It has fields such as startdate and enddate.
  • An inventory detail subrecord holds data, such as serial numbers, that describe inventory items. It contains a sublist that holds this data.
  • A subrecord exists solely to hold information about a specific record. You cannot interact with a subrecord outside the context of a parent record.

Below is the netsuite training code snippet of address Subrecord which we can use in our netsuite customization and netsuite implementation.

var recObj  = record.load({

                   type: ‘customer’,

                   isDynamic: true,

                   id: internal ID // the internal ID of the Customer

          })

          recObj .selectNewLine({

                   sublistId: ‘addressbook’

          })

var addrSubRec = recObj .getCurrentSublistSubrecord({

                   sublistId: ‘addressbook’,

                   fieldId: ‘addressbookaddress’

          })

          addrSubRec.setValue({

                   fieldId: ‘country’,

                   value: ‘Country Name’     // US/UK/NLpopulates the country field

          })

addrSubRec.setValue({

                   fieldId: ‘city’,

                   value: ‘xyz’  // the city field

})

          recObj.commitLine({

                   sublistId: ‘addressbook’

          })

          recObj.save();

Reference : netsuite.com, netsuite help  and netsuite guide.

Feel free to reach out netsuite solution providernetsuite implementationnetsuite consultation , netsuite customizationnetsuite Supportnetsuite Training  contact us at: Email : [email protected]

Facebook : https://www.facebook.com/Smiling-Coders-Netsuite-Training-Implementation-and-Support-1591053827660082/

Linkedin : https://www.linkedin.com/company/netsuite-academy/


Log out of this account

Leave a Reply