Max
Max

Reputation: 119

Netsuite SuiteScript 2.0 getSublistFields method not working

I have a User Event Script for an Invoice record (newRecord), stored as var record. In sandbox and in the browser console I use record.getSublistFields('sublist_name') which has always worked.

We just ported the User Event Script from sandbox to production and suddenly getSublistFields('sublist_name') doesn't work in the context of the script, despite there being no changes to the script. The method still works just fine using the console.

Here's a few lines from the debugger-

$ record.getLineCount('item')
> 2
$ record.getSublistFields('item')
>
$ record.getSublistFields()
>     {"type":"error.SuiteScriptError","name":"SSS_MISSING_REQD_ARGUMENT","message":"DeferredDynamicRecord.getSublistFields: Missing a required argument: sublistId","stack":["<anonymous>(N/record/recordService.js)","<anonymous>()","buildBodyData(usereventscript.js$72$debugger.user:118)","buildData(usereventscript.js$72$debugger.user:74)","_put(usereventscript.js$72$debugger.user:37)","_afterSubmit(usereventscript.js$72$debugger.user:14)","<anonymous>(usereventscript.js$72$debugger.wrap:18)","<anonymous>(usereventscript.js$72$debugger.wrap:12)","<anonymous>(usereventscript.js$72$debugger.wrap:24)","<anonymous>(usereventscript.js$72$debugger.wrap:1)"],"cause":{"type":"internal error","code":"SSS_MISSING_REQD_ARGUMENT","details":"DeferredDynamicRecord.getSublistFields: Missing a required argument: sublistId","userEvent":"aftersubmit","stackTrace":["<anonymous>(N/record/recordService.js)","<anonymous>()","buildBodyData(usereventscript.js$72$debugger.user:118)","buildData(usereventscript.js$72$debugger.user:74)","_put(usereventscript.js$72$debugger.user:37)","_afterSubmit(usereventscript.js$72$debugger.user:14)","<anonymous>(usereventscript.js$72$debugger.wrap:18)","<anonymous>(usereventscript.js$72$debugger.wrap:12)","<anonymous>(usereventscript.js$72$debugger.wrap:24)","<anonymous>(usereventscript.js$72$debugger.wrap:1)"],"notifyOff":false},"id":"","notifyOff":false} (SYSTEM_LIBS$debugger.sys#3387)

Specifically, this is an Invoice record, and as you can see from the debugger code, other regular SuiteScript 2.0 commands are working fine.

Thanks in advance for the help! Please let me know if there is any additional information I can provide.

Upvotes: 2

Views: 3688

Answers (2)

Max
Max

Reputation: 119

Thanks for the response Salman! I am working in 2.0, as you can see from the other 2.0 code before and after the code in question.

I contacted Netsuite Support and they told me that this is actually a known bug. It will supposedly be fixed in the 2017.2 release.

In the meantime I 'hacked' around it by calling getSublistFields from the oldRecord object.

Upvotes: 1

Salman
Salman

Reputation: 333

Make sure that you are working in SuiteScript 2.0 so you have to Load the record module(N/record) to work with NetSuite records.Try the below code.

var field = record.getSublistFields({
sublistId: 'item'
});

Upvotes: -1

Related Questions