This topic contains 2 replies, has 0 voices, and was last updated by david.smith 7 years, 9 months ago.

  • Author
    Posts
  • #1150

    WakaWaka

    I’ve tried various combinations of setSublistValue and setSublistText with the internal id and/or name of the tax code, but everything I try either returns an INVALID_FLD_VALUE error or INVALID_KEY_OR_REF error. The code below returns a INVALID_FLD_VALUE error. I’ve talked to other people in my company and there shouldn’t be anything wrong with how we have netsuite configured. However, I am successfully able to do this in the UI which would mean I must be doing something wrong in my code. Any input would be greatly appreciated! Feel free to let me know if more details are needed.

    Code:
    //generate some test records to use for deletion
    oppRec = nsRecord.create({ //returns a record.Record
    type: nsRecord.Type.OPPORTUNITY,
    defaultValues: {
    entity: 2694
    }
    });
    oppRec = oppRec.save(); //returns the internal id of the newly created record

    //transform opp record into estimate
    var estRec = nsRecord.transform({
    fromType: nsRecord.Type.OPPORTUNITY,
    fromId: oppRec,
    toType: nsRecord.Type.ESTIMATE
    });
    estRec.setSublistValue({
    sublistId: ‘item’,
    fieldId: ‘item’,
    value: 25, //ball-point pens
    line: 0
    });
    estRec.setSublistValue({
    sublistId: ‘item’,
    fieldId: ‘quantity’,
    value: 4,
    line: 0
    });
    estRec.setSublistValue({
    sublistId: ‘item’,
    fieldId: ‘taxcode’,
    value: -453,
    line: 0
    });
    estRec = estRec.save();
    This is a cached copy. Click here to see the original post.

  • #1151

    david.smith

    1) Check your tax code id. To view existing tax codes in your NetSuite account, go to Setup > Accounting > Taxes > Tax Codes (Administrator).

    2) Use line “1” not 0


    WakaWaka replied on 02/21/2017, 09:51 AM: I’ve checked the tax code id many times over.

    Using line 1 get me an UNEXPECTED_ERROR code thrown on the first estRec.setSublistValue

  • #1152

    david.smith

    Sorry, my bad. I didn’t look closely enough to see you were using SS2.0. I’ve been bouncing back and forth (old habits).

    Try this, make all of your numeric values strings.

    Code:

    estRec.setSublistValue({ sublistId: ‘item’, fieldId: ‘taxcode’, value: ‘-453’, line: 0 });

You must be logged in to reply to this topic.