I have a restlet that creates purchase orders, and when they are first created I want to set the document number (tranid) to “n/a”, and I’ll handle the actual numeration later on in a separate process. The “n/a” value is set in a user event script (beforeSubmit) because I want the same behavior regardless of whether the PO is created through the integration or in the UI.
I have allowed overwriting the document number for purchase orders, and for the majority of cases it works as expected, but then suddenly there’s a stray case where the sending system gets the response below. They do a few retries but the same few purchase orders return the same error on every attempt. I can’t see any difference between these requests and ones that go through as expected. Does anyone know what might cause it and/or how to fix it? I know you get this question if you do it in the UI, but it doesn’t make sense in a script context and I don’t get why most requests work (this happens in about 1 out of 1000 requests)
{"type":"error.SuiteScriptError","name":"USER_ERROR","message":"Reference No.n/a is already used. Click OK to replace with the next available number","stack":["Error\n at RecordInvoker.save (suitescript/resources/javascript/record/serverRecordService.js:371:13)\n at NetSuiteObject.thenableFunction() (suitescript/resources/javascript/record/proxy.js:115:24)\n at post [...],"notifyOff":false},"id":"","notifyOff":false,"userFacing":true}