I have a user event script that is supposed to be ...
# suitescript
s
I have a user event script that is supposed to be capturing a custom error on CSV import. Instead of displaying the error message, it fails and writes "An unexpected SuiteScript error has occurred". I debugged the hell out of it with logging and seems to not like what I'm doing to throw the message. I was even able to log the error itself. This is what I'm doing:
Copy code
throw error.create({
          name: 'DUPLICATE_RECORDS_FOUND',
          message: `Source Account ID: ${newRecord.getValue('externalid')}, Recipient Account ID: ${duplicatesFound[0].id}`
        }).message
Here are the logged results to those values: duplicatesFound[0].id: 122202 newRecord.getValue('externalid'): 122202
c
Have you tried throwing a plain message without the interpolated variables?
b
throw an Error, or an error.Error, dont throw a string
👍 1
s
Okay. I think I got to the bottom of it. I was trying to use async and that seemed to be the issue. Error.create doesn't seem to have built in promises and maybe that was the issue?
After reverting all the async logic, it seemed to work for me.
That's what I get for trying to be fancy.