Skip to content

Instantly share code, notes, and snippets.

@iloveitaly
Last active February 22, 2024 21:52
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iloveitaly/db7d532e772b67f5b81d0199d094301f to your computer and use it in GitHub Desktop.
Save iloveitaly/db7d532e772b67f5b81d0199d094301f to your computer and use it in GitHub Desktop.
Simple utilities to help ease NetSuite SuiteScript development
// Author <mike@suitesync.io>
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