This topic contains 4 replies, has 0 voices, and was last updated by budysutjijati 6 years, 11 months ago.

  • Author
    Posts
  • #18106

    budysutjijati

    Hi Fellow NetSuiters,

    I’m running into this issue where I cannot create a sales order from SuiteScript. I constantly get the below message when I try to call the RESTlet:

    Code:
    error code: JS_EXCEPTION
    error message:{“type”:”error.SuiteScriptError”,”name”:”INVALID_FLD_VALUE”,”message”:”You have entered an Invalid Field Value 387 for the following field: item”,”stack”:[“anonymous(N/recordService)”,”doGet(/SuiteScripts/IMS Demo/cadran_rl_create_sales_order.js:34)”],”cause”:{“type”:”internal error”,”code”:”INVALID_FLD_VALUE”,”details”:”You have entered an Invalid Field Value 387 for the following field: item”,”userEvent”:null,”stackTrace”:[“anonymous(N/recordService)”,”doGet(/SuiteScripts/IMS Demo/cadran_rl_create_sales_order.js:34)”],”notifyOff”:false},”id”:””,”notifyOff”:false}
    While I’m following the NetSuite documentation https://system.netsuite.com/app/help…267258059.html and https://system.netsuite.com/app/help…ead_4273196114 for creating a transaction record I cannot come up with a solution anymore and I hope someone can tell me what I’m doing wrong here. For testing purposes I don’t POST or GET any data and, so I’ve entered the entity id 80 and iternal item 387 in the code. I tried single, double and no quotes without any success.

    Code:
    function doGet(requestParams) {
    //return “Hello World”;

    var rec = record.create({
    type: record.Type.SALES_ORDER,
    isDynamic: true,
    defaultValues: {
    entity: 80
    }
    });

    rec.selectNewLine({ //add a line to a sublist
    sublistId: ‘item’ //specify which sublist
    });

    rec.setCurrentSublistValue({ //set item field
    sublistId: ‘item’,
    fieldId: ‘item’,
    value: ‘387’
    });

    rec.setCurrentSublistValue({
    sublistId: ‘item’,
    fieldId: ‘quantity’,
    value: 1
    });

    //repeat above pattern to set the rest of the line fields

    rec.commitLine({ //writes the line entry into the loaded record
    sublistId: ‘item’
    });

    rec.save({
    enableSourcing: false,
    ignoreMandatoryFields: false
    });
    return rec;

    }

    And in case I remove the isDynamic option, I get the following error message:

    Code:
    error code: JS_EXCEPTION
    error message:org.mozilla.javascript.EcmaError: TypeError: Cannot find function selectNewLine in object DeferredDynamicRecord. (/SuiteScripts/IMS Demo/_rl_create_sales_order.js#30)

    Thanks in advance!
    This is a cached copy. Click here to see the original post.

  • #18107

    pcutler

    Sorry if this is obvious, but have you double-checked that the inactive checkbox is not checked on item internal ID 387?

    Also, make sure that this item meets the saved search criteria if the custom form being used has its items filtered by a saved search.

  • #18108

    budysutjijati

    The item is active.

    I can enter a sales order from the UI for a customer for that specific item with a standard form. Why can’t it be done by SuiteScript, can it be something with permissions? If so, then I would have expect a different error message. I will try to find out if a custom form or anything else is causing this issue.

    When I tried another item, I got the same response. Below the error message i’ve received by e-mail:

    Code:
    Account: XXXXXXXXXXXXXXXXX
    Environment: Production
    Date & Time: 12/12/2017 8:38 am
    Execution Time: 0.00s
    Script Usage: 0
    Script: Create Sales Order RESTlet
    Type: RESTlet
    Function: get
    Error: JS_EXCEPTION
    {“type”:”error.SuiteScriptError”,”name”:”INVALID_FLD_VALUE”,”message”:”You have entered an Invalid Field Value 1180 for the following field: item”,”stack”:[“anonymous(N/recordService)”,”doGet(/SuiteScripts/Irl_create_sales_order.js:48)”],”cause”:{“type”:”internal error”,”code”:”INVALID_FLD_VALUE”,”details”:”You have entered an Invalid Field Value 1180 for the following field: item”,”userEvent”:null,”stackTrace”:[“anonymous(N/recordService)”,”doGet(/SuiteScripts/rl_create_sales_order.js:48)”],”notifyOff”:false},”id”:””,”notifyOff”:false}

  • #18109

    pcutler

    It could be related to permissions – if the user has a restriction that would prevent them from seeing the item, then this is the error you would expect. Have you tried testing using the administrator role?

  • #18110

    budysutjijati

    So, I’ve finally figured it out. The token based auth role, which I had created specifically for the RESTlet, had only permission to create sales orders for specific customers. While I was always creating sales order with my own role in the UI, instead of the token based auth role, I did not see this. So case closed and thanks for your help!

You must be logged in to reply to this topic.