NetSuite Script Error: INVALID_KEY_OR_REF - Invalid entity reference key nnnnnnnn

NetSuite Script Error: INVALID_KEY_OR_REF - Invalid entity reference key nnnnnnnn


When a Sale or Return is written to NetSuite you may get this error thrown and the transaction appears on the Fail Queue of the device. eg. Request failed: bad request (400) {"error" : {"code" : "INVALID_KEY_OR_REF", "message" : "Invalid entity reference key 10397253

This means that you are trying to write to NetSuite using an invalid/missing entity (customer). A similar message can be displayed for items. 

For the most part, this is caused by a customer (or item) existing in your local device; but has been removed from NetSuite. The most common cause is when customers are merged in NetSuite and not co-ordinated with a full sync at the terminals.

Resolving this issue will depend on the root cause. If it was as a result of a customer merge; it is unrecoverable and the Fail Queue would need to be sent, cleared and the transaction entered manually. If it was the result of a customer being de-activated, the customer can be re-activated and then on the next sync the transaction will then get re-created.

If this keeps persisting, the safest thing to do is perform a full sync on all the terminals to prevent further occurences. You can force a full sync from POS Settings record (this will force a full sync the following day) or perform one manually at each terminal. This will ensure a fresh set of data (for items and customers) is cached locally. 

  1. Force Full Sync should be set to a date in the future (eg. tomorrow). 
  2. Once devices start doing a full sync, you may encounter a SSS_REQUEST_LIMIT_EXCEEDED error. This is because too many syncs are running concurrently for what you have licensed with NetSuite. The best way to prevent this is to full sync the terminals in groups not to exceed the concurrency you are licensed for.
  3. Merges of customer/entity records should be co-ordinated carefully with well timed full syncs.