im trying to add a preferred bin to an item [on cr...
# suitescript
l
im trying to add a preferred bin to an item [on create] but im getting an error because the sublist doesnt exist yet since there are no values yet. how do i fix this?
c
After create is what you want if you isn't already
l
it is an aftersubmit function
🤨 1
d
Are you setting usebins to true?
l
yes, it is true
d
Bin location?
l
message has been deleted
yes
d
I'd post more of your code and the exact error in that case.
s
Have you tried doing this not on create? As in are you 100% sure that sublist is scriptable?
l
message has been deleted
i am getting an unexpected error
s
line indices start at 0, not 1
Also your log.debug, put
e
or
e.message
in the details
l
i did 0 for the index
Copy code
{
  "type": "error.SuiteScriptError",
  "name": "UNEXPECTED_ERROR",
  "message": null,
  "stack": [
    "anonymous(N/serverRecordService)",
    "afterSubmit(/SuiteScripts/PreferredBins.js:14)"
  ],
  "cause": {
    "type": "internal error",
    "code": "UNEXPECTED_ERROR",
    "details": null,
    "userEvent": "aftersubmit",
    "stackTrace": [
      "anonymous(N/serverRecordService)",
      "afterSubmit(/SuiteScripts/PreferredBins.js:14)"
    ],
    "notifyOff": false
  },
  "id": "6b941e3a-67f8-459e-ac9b-de3a4cc1a93c-2d323032312e30342e3239",
  "notifyOff": false,
  "userFacing": false
}
n
So is it in an afterSubmit or beforeSubmit function?
s
Have you tried modifying an already existing sublist to make sure its scriptable?
l
its actually working now. one of my indices was still one
thank you for all your help