I am trying to refresh a value (qty-on-hand) on a ...
# suitescript
m
I am trying to refresh a value (qty-on-hand) on a custom record when viewed and on editing. It works fine on the edit page using clientscript (pageInit), but this clientscript function doesn't run on view. I tried a userevent (beforeLoad) and it produces this ambiguous error
Copy code
{
  "type": "error.SuiteScriptError",
  "name": "UNEXPECTED_ERROR",
  "message": "An unexpected SuiteScript error has occurred",
  "stack": [
    "Error\n at RecordInvoker.setSublistValue (suitescript/resources/javascript/record/serverRecordService.js:421:5)\n at NetSuiteObject.thenableFunction() (suitescript/resources/javascript/record/proxy.js:115:24)\n at Object.beforeLoad (/SuiteScripts/UE-MaterialReturnSourceData.js:140:29)"
  ],
  "cause": {
    "type": "internal error",
    "code": "UNEXPECTED_ERROR",
    "details": "An unexpected SuiteScript error has occurred",
    "userEvent": null,
    "stackTrace": [
      "Error\n at RecordInvoker.setSublistValue (suitescript/resources/javascript/record/serverRecordService.js:421:5)\n at NetSuiteObject.thenableFunction() (suitescript/resources/javascript/record/proxy.js:115:24)\n at Object.beforeLoad (/SuiteScripts/UE-MaterialReturnSourceData.js:140:29)"
    ],
    "notifyOff": false
  },
  "id": "dc4ce98d-c15c-48cb-b239-bad1ae18ec39-2d323032332e30312e3139",
  "notifyOff": false,
  "userFacing": true
}
It complains about this line, I don't know why:
Copy code
currentRecord.setSublistValue({
  sublistId: "...",
  fieldId: "...",
  value: qtyOnHand,
  line: i,
});
m
Oh, so there is no way to do it then.
Thanks, I need to read more carefully.