I'm trying to inject an entry into my system notes...
# suitescript
c
I'm trying to inject an entry into my system notes that a line item has been closed in a sales order. It requires a reason (in a custom field at the transaction line level) and all is working save for putting in a system note saying that this particular item was closed. Problem is I am getting a "Type Error log.debug is not a function" when executing the following. Can anyone tell me what I've done wrong?
define([ "N/record", "N/runtime"], function(r, log) {
function validateLine(scriptContext) {
var recCurrent = scriptContext.currentRecord;
var itemClosed = recCurrent.getCurrentSublistValue({
sublistId : 'item',
fieldId : 'isclosed'
});
var whyClosed = recCurrent.getCurrentSublistValue({
sublistId : 'item',
fieldId : 'custcol_reason_closed'
});
if (itemClosed && !whyClosed) {
alert("Please enter a reason for the items closed.");
return false;
}
else if (itemClosed && whyClosed) {
log.debug({details:"Item Closed" + itemClosed});
return true;
}
}
return {
validateLine : validateLine
};
});
b
Variable shadowing
Global log hidden by the local log
The local log is a badly named runtime module which does not have a debug function
👍 1
s
in addition, you're importing the
N/runtime
module as
log
which probably isn't what you want.
c
okay, with you so far
s
FWIW, if you use typescript you never have these sorts of misaligned define() method definitions. The
import
syntax I use in TS always generates correct define() arguments
-without me ever needing to think about it.
s
define([ "N/record", "N/runtime"], function(r, log) {
, that is the problem right there. runtime.debug isnt a thing