Last active
February 22, 2024 21:52
-
-
Save iloveitaly/db7d532e772b67f5b81d0199d094301f to your computer and use it in GitHub Desktop.
Simple utilities to help ease NetSuite SuiteScript development
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Author <[email protected]> | |
function isUserInterfaceContext() { | |
var context = nlapiGetContext(); | |
var executionContext = context.getExecutionContext(); | |
return executionContext == 'userinterface'; | |
} | |
function startsWith(str, searchString) { | |
return str.indexOf(searchString) === 0; | |
} | |
function isZero(obj) { | |
return parseFloat(obj) == 0.0 | |
} | |
function debugObject(obj) { | |
for (var i in obj.getAllFields()) { | |
nlapiLogExecution('DEBUG', i) | |
} | |
} | |
// debugSearchResult(results) | |
function debugSearchResult(searchResults) { | |
var searchColumns = searchResults[0].getAllColumns() | |
var output = "" | |
for (var i in searchColumns) { | |
output += debugSearchColumn(searchColumns[i]) | |
} | |
return output | |
} | |
// debugSearchColumn(results[0].getAllColumns()[1]) | |
function debugSearchColumn(searchResultColumn) { | |
var output = "" | |
output += searchResultColumn.getLabel() + ", " | |
output += searchResultColumn.getName() + ", " | |
output += searchResultColumn.getSummary() + ", " | |
output += searchResultColumn.getJoin() + ", " | |
log(output) | |
// return & log for easy debugging via the "Evaluate Expressions" panel | |
return output | |
} | |
function log(msg) { | |
nlapiLogExecution('DEBUG', msg); | |
} | |
function error(msg) { | |
nlapiLogExecution('ERROR', msg); | |
} | |
function isEmpty(obj) { | |
return obj === undefined || obj === null || obj === ""; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment