Reputation: 78
I'm using a scheduled script to get the line count of a sublist on a customer record so I can loop through the list. The list items are a custom record type (SOW_rec) and are children of the customer. I am able to load the record but lineCount only returns a -1 no matter which sublist ID I try. How do I find the sublist ID where the sublist is in a parent-child relationship? I have tried looking in &XML=T but there is no sublist data in there.
var companyRecord = record.load({
type: record.Type.CUSTOMER,
id: company,
isDynamic: true,
});
log.debug({
title: 'companyrecord',
details: companyRecord
});
var lineCount = companyRecord.getLineCount('SOW_Rec');
log.debug({
title: 'linecount',
details: lineCount
});
Upvotes: 1
Views: 7301
Reputation: 71
NetSuite Help Article 65795 details the naming convention for Custom Child Record Sublist IDs
The internal ID for a custom child record sublist is recmach + > field_id_for_the_parent_field (for example: recmachcustrecord111).
NetSuite expects all lower case for the Id.
Upvotes: 2
Reputation: 342
Check the "Allow Child Record Editing" checkbox on the child record that you are trying to access with the .getLineCount
command.
Also, as dcrs mentioned, the linecount command should be var lineCount = companyRecord.getLineCount({sublistId:"RECMACHCUSTRECORD...."});
Upvotes: 2
Reputation: 304
Your code for line count is incorrect. You're missing the parameter needed for the sublist. If this is a child record it will be linked by the field listed with the "record is parent" checked.
var lineCount = companyRecord.getLineCount({sublistId:"RECMACHCUSTRECORD...."});
Upvotes: 1
Reputation: 5286
When I look at the XML structure of a Customer record (using &xml=T appended to the URL), I can see the sublist data there. However, in a thoroughly effective effort to confuse, NetSuite has called the relevant XML element <machine>
rather than <sublist>
or something you might naturally think of. So try searching for "machine" on the customer record after loading it with &xml=T - you should see several references to it (open and close tags for each sublist) each with <line>
sub-elements.
Once you've located the <machine>
elements, you will see each has a name
attribute which is the sublist ID you're looking for.
Upvotes: 0