From the help:
nlapiCreateError(code, details, suppressNotification)
Creates an nlobjError (complete with stacktrace) that can be thrown to abort script execution.
This code: function SS_OnBeforeLoad(type) { // Test nlobjError and the stacktrace property try { a(); } catch(e) { var msg = new String(); if(e instanceof nlobjError) { msg += 'nlobjError Exceptionn'; msg += 'Code: ' + e.getCode() + 'n'; msg += 'Details: ' + e.getDetails() + 'n'; msg += 'UserEvent: ' + e.getUserEvent() + 'n'; msg += 'InternalId: ' + e.getInternalId() + 'n'; var stacktrace = e.getStackTrace(); for ( var i = 0; stacktrace != null && i < stacktrace.length; i++ ) { if ( i == 0 ) { msg += 'Stack Trace' + 'n'; } msg += stacktrace[i] + 'n'; } } else { msg = 'Javascript Exceptionn'; msg += e.toString(); } nlapiLogExecution('DEBUG', 'Exception type test', msg); } } function a() { b(); } function b() { throw nlapiCreateError('TEST_ERROR', 'This exception should have a stack trace', true); } Logs:
Javascript Exception
Code: TEST_ERROR
Details: This exception should have a stack trace
Sooooo....? What gives?Looks like nlapiCreateError is busted.