SuiteScript – Accessing a Custom Record Type Sublist

This is documented in several NetSuite and non-NetSuite articles. I read them all and still found it almost impossible to decipher how to programmatically read a custom record type sublist.

Feel free to start with SuiteAnswers article 65795, or Google “Sublist recmach”, or whatever else you can think of… Or just read this! In my example I’m using two custom record types. The first is the parent of the second. The second is a sublist of the first.

Here is the parent custom record type. Nothing is important here except the name: customrecord_logic_software_agreements

Here is the child custom record type where it is very important to check the “Allow Child Record Editing.” Otherwise, nothing works! It is also vitally important to include a reference to the parent table. Here you see my reference to “Software Agreement.” Notice it is of type “List/Record” and the reference is to the custom record type “Software Agreements.”

Next, and also essential, is the definition of the foreign-key relationship between child and parent. In my case, custrecord_logic_sft_line_agreement. It is important to make sure to note that this field is the link to the parent record. You do that by checking “Record is Parent.”

Now, here is where the magic begins. The sublistId is the scriptId of the foreign-key field prefixed with “recmach”. Crazy, I know! But… It works!

I hope this saves you a lot of time. And more importantly, I hope this saves ME a lot lot of time the next time I want to programmatically reference a non-standard record type as a sublist.

Happy coding!

2 thoughts on “SuiteScript – Accessing a Custom Record Type Sublist

  1. Shubs says:

    Super helpful Kevin, but have you been able to reference the sub list in Advanced PDF templates?

    I’ve been able to identify the field but then I put ${record.remachcustrecord_id.field_id} nothing shows up.

    My basic setup is simple to yours where my transaction record (invoice) is parent to a custom record (roster).


  2. Shubs, I’m afraid I have not tested accessing the sublist in a PDF template. To see if it is available, uncheck the show code checkbox and review your available fields in the GUI editor. Then, if all else fails, add a button and create your printed version using ‘N/render’ module. We know that works.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s