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

  • Author
    Posts
  • #1843

    zshaikh

    I have created a userevent in SuiteSript 2.0. In the beforeSubmit event, I got the workorder object from context. Now when I call getSublistText function on workorder object, it throws following exception:

    Exception by NetSuite:

    {

    “type”: “error.SuiteScriptError”,

    “name”: “SSS_INVALID_API_USAGE”,

    “message”: “Invalid API usage. You must use getSublistValue to return the value set with setSublistValue. “,

    “stack”: [

    “anonymous(N/recordService)”,

    “beforeSubmit(SuiteBundles/Bundle 118273/SES – TodoFut/userevent/f3_workorder_userevent.js:38)”

    ],

    “cause”: {

    “type”: “internal error”,

    “code”: “SSS_INVALID_API_USAGE”,

    “details”: “Invalid API usage. You must use getSublistValue to return the value set with setSublistValue. “,

    “userEvent”: “beforesubmit”,

    “stackTrace”: [

    “anonymous(N/recordService)”,

    “beforeSubmit(SuiteBundles/Bundle 118273/SES – TodoFut/userevent/f3_workorder_userevent.js:38)”

    ]

    },

    “id”: “”

    }

    User Event Code:

    Code:
    /**
    * Created by zshaikh on 8/23/2016.
    */
    /**
    * @NApiVersion 2.x
    * @NScriptType UserEventScript
    */
    define([“N/record”, “N/search”, “N/ui/serverWidget”, “N/util”, “N/log”], function (record, search, serverWidget, util, log) {
    function beforeSubmit(context) {
    // do not execute any code if type is not create
    // only in case of Create, further code will be executed
    if (context.type !== context.UserEventType.CREATE) {
    return;
    }
    var form = context.form;
    var workorder = context.newRecord;

    // returns an empty string
    var lineItemFields = workorder.getSublistFields({ sublistId: “item” });
    log.debug(“lineItemFields: “, JSON.stringify(lineItemFields));

    // throws exception
    var playerName = workorder.getSublistText({
    sublistId: “item”,
    fieldId: “custcolcustcol20”,
    line: (lineItemsCount – 1)
    });

    log.debug(“playerName: “, playerName);
    }

    return {
    beforeSubmit: beforeSubmit
    };
    });

    What could be the cause of this error and what are alternatives?
    This is a cached copy. Click here to see the original post.

You must be logged in to reply to this topic.