1
votes

Im creating a script to create a Sales Order on netSuite, but im getting the fallowing error:

"INVALID_FLD_VALUE","message":"You entered an invalid field value of 10807 for the following field: entity"

What im doing wrong?

There is the Code:

  var salesOrder;
  var customerid;

  var salesOrder = record.create({
    type: record.Type.SALES_ORDER,
    isDynamic: true
  });

  var ENTITY_VALUE = 10807;

  salesOrder.setValue({fieldId:'entity',value:ENTITY_VALUE})

  salesOrder.selectNewLine({
    sublistId: 'item'
  });

  salesOrder.setCurrentSublistValue({
    sublistId: 'item',
    fieldId: 'item',
    value: 1175
  });

  salesOrder.setCurrentSublistValue({
    sublistId: 'item',
    fieldId: 'quantity',
    value: 1
  });

  salesOrder.setCurrentSublistValue({
    sublistId: 'item',
    fieldId: 'rate',
    value: objectJson.total_tickets_revenue
  });

  salesOrder.setCurrentSublistValue({
    sublistId: 'item',
    fieldId: 'amount',
    value: objectJson.total_tickets_revenue
  });

  salesOrder.setCurrentSublistValue({
    sublistId: 'item',
    fieldId: 'taxcode',
    value: 5
  });

  salesOrder.commitLine({ //writes the line entry into the loaded record
    sublistId: 'item'
  });

  salesOrder.save({
    ignoreMandatoryFields: true,
    enableSourcing: false
  })
3

3 Answers

2
votes

I'm guessing entity 10807 is not a customer.

You'll save yourself some work if you do:

var salesOrder = record.transform({fromType:'customer', fromId:'10807', toType:'salesorder', isDynamic:true});
1
votes

Please re-activiate entity ID 10807. It's inactive.

0
votes

Are you using OneWorld or any location/ department restrictions?

Sometimes invalid value errors will be thrown when the role running the script doesn’t have access to the subsidiary that the referenced record belongs to