0
votes

I'm trying to get the sub lists from net suite of Customers data like

 var lineCount = customer.getLineItemCount("subRec");

for thatI'm getting the line count, with in having the multi sub list like

"subRec": [{
"days": "60",
"multisub1": {
    "internalid": "1",
    "name": "shell"
}

}, { "days": "60", "multisub2": { "internalid": "400", "name": "shell2" } }]

It is sublist within subrecord like in the above how can i access the multisub1 record using suite script.

how can i access the such type data from suite script using API...

for getSubrecord() i'm getting like TypeError: Cannot find function getSubrecord in object nlobjRecord. and i'm net suite 1.0 version.

thanks in Advance!

2
Is it a sublist subrecord(subrecord within sublist)? Could you provide some example?Avi

2 Answers

1
votes

To get a sublist from a subrecord, you first need to fetch subrecord and then update sublist in it.

subrecord = customerRecord.getSubrecord({ fieldId: SUBRECORD_FIELD_ID });
    // now read/set values from subrecord in the same way as you would from a record
sublistLineCount = subrecord.getLineCount({ sublistId: SUBRECORD_SUBLIST_ID });
var value = subrecord.getSublistValue({ sublistId: SUBRECORD_SUBLIST_ID, fieldId: SUBRECORD_SUBLIST_FIELD_ID, line: SUBRECORD_SUBLIST_LINE_NO });

Note You don't need to save a subrecord. It is saved automatically once you save the parent record.

0
votes

You can use like this:

var customer = nlapiLoadRecord('customer','recordId');
    var count = customer.getLineItemCount("subRecId");
    
    customer.selectLine('subRecId',lineNumber);
   var multiSubRec =  customer.getCurrentLineItemSubrecord('subRecId','multisubIdLineFiedld');
var mutiSubRecCount = multiSubRec.getLineItemCount('multisubId');
multiSubRec.getLineItemValue('mutiSubRecFieldId',LineNumber);