Stoic Software I'd like to thank you for the video. After a couple hours of fighting with a sublist, your video gave me the answer I needed. I didn't realize they had changed the index number to be zero based. I wish they had documented it a little better or gave a more meaningful exception, but either way I appreciate the vid . I was approaching the hair pulling stage.
@kunaldhuria39352 жыл бұрын
You are a life saver man! God bless you
@manjulaamarasekara80936 жыл бұрын
Hi Stoic, Can you also demonstrate how to add values to a sublist from inside of a for-loop? That is, I have a list of search results and I need to add them to a sublist of my "form" object. I am using setSublistValue() method to do it. But the values do not get added to the sublist.
@hlf_coder62726 жыл бұрын
Manjula Amaresekara I would first make sure you're using the proper sublist field id in your call to setSublistValue. If the field id you're using doesn't exist, it doesn't throw an exception, but your item isn't added, which seems to be what you're describing. In other words, if you add a field to your sublist like this: sublist.addField({ id: 'custpage_tranid', label: 'Transaction Id', type: serverWidget.FieldType.TEXT }); When you call setSublistValue, make sure the 'id' property is set correctly. Something like the code below, which is partial code that more or less does what you're looking to do. Meaning, it's a working example of looping through search results and adding them to a sublist. I can't really post the whole thing here but hopefully it's enough to help. for (var i = 0; i < studentInvoices.length; i++) { var currentInvoice = studentInvoices[I]; sublist.setSublistValue({ id: 'custpage_tranid', line: i, value: currentInvoice.getValue({name: 'tranid'}) }); }
@ryancole61656 жыл бұрын
Hi, any idea how to delete all line items before adding programmatically? I'm receiving the following error: error.SuiteScriptError\",\"name\":\"SSS_INVALID_SUBLIST_OPERATION var itemCount = order.getLineCount({"sublistId": "item"}); for (var i = 0; i < itemCount; i++) { try { order.removeLine({ sublistId: "item", line: i }); log.debug({details:"removed line = " + i}); } catch (e) { // Fails silently log.error({details:"error = " + e}); } }
@grubes346 жыл бұрын
When you remove lines, you need to start at the end of the list and go backward. If you start at the beginning and move forward, you will loop too far and eventually start removing non-existent lines. Start your loop at `itemCount` and work your way back to 0.
@ryancole61656 жыл бұрын
Interesting. It works however I had to use "ItemCount -1" as the sublist array starts at 0. Thanks again.
@umeshshukla76337 жыл бұрын
A very helpful video, can you please give some idea on "How to debug SuiteScript 2.0 (RESTlet) in Netsuite Debugger?" Thanks in advance.