Jader Alves
Jader Alves

Reputation: 53

How to fix: "INVALID_FLD_VALUE" on entity creating a Sales Order

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
  })

Upvotes: 1

Views: 3270

Answers (3)

Beauregard D
Beauregard D

Reputation: 107

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

Upvotes: 1

bknights
bknights

Reputation: 15447

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

Upvotes: 0

bknights
bknights

Reputation: 15447

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});

Upvotes: 2

Related Questions