This topic contains 7 replies, has 0 voices, and was last updated by starlingMark 7 years, 8 months ago.

  • Author
    Posts
  • #1805

    rajohnson2004

    I cannot figure out how to set the values on a sales order sublist with this dynamic record thing…below is code

    Code:
    /**
    * @NApiVersion 2.0
    * @NScriptType UserEventScript
    * @NModuleScope SameAccount
    */
    define([‘N/record’, ‘N/runtime’, ‘N/error’,’N/xml’, ‘N/file’, ‘N/email’, ‘N/search’, ‘N/format’, ‘N/crypto’, ‘N/https’, ‘N/encode’, ‘N/config’, ‘N/task’],
    function(record, runtime, error, xml, file, email, search, format, crypto, https, encode, config, task)
    {

    function beforeSubmit(context) {
    var salesOrder = context.newRecord;
    var salesOrderId = salesOrder.id;
    var numLines = salesOrder.getLineCount({
    sublistId: ‘item’
    });

    var anchorNames = new Array();
    var anchorQtys = new Array();

    for (var i = 0; i This is a cached copy. Click here to see the original post.

  • #1806

    JacksonP

    Have you tried insertLine? I vaguely remember having the same issue but I can’t remember from which script. This might help…

    Code:
    for (var i = 0; i < negativeBin.length; i++) {

    negativeAdjustment.insertLine({
    sublistId: 'inventory',
    line: i
    });
    negativeAdjustment.setSublistValue({
    sublistId: 'inventory',
    fieldId: 'item',
    line: i,
    value: itemId
    });
    negativeAdjustment.setSublistValue({
    sublistId: 'inventory',
    fieldId: 'binnumbers',
    line: i,
    value: negativeBin[i]
    });


    rajohnson2004 replied on 09/16/2016, 01:21 PM: Thanks, Jackson. It definitely got rid of the issue.

  • #1807

    ironside

    Hmm, setSublistValue() isn’t supported on dynamic records, so I’m at a loss at how that code could get rid of the issue?

  • #1808

    starlingMark

    I just ran into this same issue. I am on a before submit trigger and trying to retrieve information from a sublist. I have to retrieve several columns from each line, so to try and minimize the lines of code required I wanted to do a selectLine and then getCurrentSublistValue. Then I hit the same error as mentioned by the OP.

    chanarbon Can you give us any insight on this? The documentation suggests that this should work just fine.

  • #1809

    chanarbon

    Yes. For dynamic, you must use setCurrentSublist() which means that you have to selectLine() . From what we currently have, the best solution is the iteration on the lines. Thanks for the feedback for sublist. Knowing the difficulty in the development with sublists in 2.0 would be a good feedback to our end to improve our end.

  • #1810

    starlingMark

    Thanks for the reply chanarbon. Glad to see that NS has some resources taking this kind of feedback!

  • #1811

    jejacob

    Hi starlingMark,

    Am not sure which documentation you are referring to. But this is explicitly stated in Help Guide: https://netsuite.custhelp.com/app/an…etsublistvalue

    Method Description
    Sets the value of a sublist field. (standard mode only) or Deferred Dynamic mode

    When working in dynamic mode, set a sublist field value using the following methods: Record.selectLine(options)
    Record.setCurrentSublistValue(options)
    Record.commitLine(options) Method Description
    Sets the value of a sublist field. (standard mode only)

    When working in dynamic mode, set a sublist field value using the following methods:Record.selectLine(options)
    Record.setCurrentSublistValue(options)
    Record.commitLine(options)

  • #1812

    starlingMark

    jejacob – Right you are! I was confusing a record object with a currentRecord object. Thank you for this.

You must be logged in to reply to this topic.