Skip to content

Instantly share code, notes, and snippets.

View benjsicam's full-sized avatar
:octocat:
Kaizen

Benj Sicam benjsicam

:octocat:
Kaizen
View GitHub Profile
@benjsicam
benjsicam / netsuite_recaptcha_suitelet.js
Last active August 16, 2018 02:30
A suitelet that acts as a proxy for reCaptcha verification.
var CAPTCHA_VERIFICATION_URL = 'https://www.google.com/recaptcha/api/verify'; //This is the verification URL
var CAPTCHA_PRIVATE_KEY = '6Lf1-OASAAAAAFkwdm0fLSAPErgLRw54VzF4aPrO'; //This is the private key we've obtained from Part 1 of this tutorial
/**
*
* @param {nlobjRequest} request Request object
* @param {nlobjResponse} response Response object
* @returns {Void} Any output is written via response object
*/
@benjsicam
benjsicam / netsuite_recaptcha_css.js
Last active March 3, 2022 00:34
A client side script which executes on submit of an Online Lead Form and sends a POST request to a back-end suitelet which does the reCaptcha verification.
/*
* This is the external URL of the Suitelet we've created on Part 3 of this tutorial.
*/
var CAPTCHA_VERIFICATION_SUITELET_URL = 'https://forms.na1.netsuite.com/app/site/hosting/scriptlet.nl?script=89&deploy=1&compid=TSTDRV262509&h=cd6d5783f52fba53b0f3';
/**
* Executes when the user clicks the Submit button.
* @returns {Boolean} True to continue save, false to abort save
*/
@benjsicam
benjsicam / netsuite_date_time_zone_util.js
Last active June 21, 2016 11:54
A JavaScript utility for converting date/time zone objects in NetSuite to different time zones.
DateTimeZoneUtils = {
/**
* This is a method to get the current Date/Time
* based on the time zone offset specified.
*
* @param timeZoneOffSet {Number} - The time zone offset.
*
* @returns {Date} date - The Date/Time Object based on the time zone offset specified.
*/
getCurrentDateTime: function (timeZoneOffSet) {
@benjsicam
benjsicam / netsuite_date_time_zone_util_test.js
Last active December 17, 2015 04:49
Demonstrates how to use netsuite_date_time_zone_util.js and tests its functionality.
/*
* Demonstrates how to use the utility.
*/
var dateTimeInUSWestCoast = new Date();
var convertedDateTime = DateTimeZoneUtils.getCurrentDateTime(1);
var convertedDateTimeText = DateTimeZoneUtils.getCurrentDateTimeText(1, 'datetimetz');
var convertedCompanyDateTime = DateTimeZoneUtils.getCompanyCurrentDateTime();
var convertedCompanyDateTimeText = DateTimeZoneUtils.getCompanyCurrentDateTimeText('datetimetz');
@benjsicam
benjsicam / netsuite-online-form-template.html
Last active June 5, 2024 20:00
NetSuite Online Lead Form Template using HTML5, Bootstrap, Google reCaptcha, and jQuery.
<!-- Declare HTML5 DOCTYPE. This is needed because Bootstrap will no work if the DOCTYPE isn't HTML5 -->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Registration Form</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Include Bootstrap CSS from CDN -->
<link href="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet">
@benjsicam
benjsicam / netsuite_suitetalk_file_download.java
Last active December 27, 2023 23:59
A code snippet that demonstrates how to download a file from the NetSuite file cabinet and save onto a local folder.
private void getFileAndSaveLocally() throws IOException {
//Login to NetSuite Web Service
/*
* Get the File from NetSuite by invoking the get operation
*/
_console.writeLn("Enter Internal ID of the File: ");
String internalID = _console.readLn();
RecordRef NSFileRef = new RecordRef();
NSFileRef.setInternalId(internalID);
/**
* WIZARD CODE
* This is the step where you create your file upload page.
*/
if (step == 'custstep_upload_file') {
var fileField = this.wizard.addField('custpage_file', 'select', 'File');
var uploadButton = this.wizard.addField('custpage_btn_upload', 'inlinehtml', 'Browse');
fileField.setPadding(2);
fileField.setMandatory(true);
@benjsicam
benjsicam / netsuite_file_upload_wizard.js
Last active October 29, 2021 19:38
This code is a NetSuite Wizard or NetSuite Assistant which has a File Upload functionality.
/**
* File Upload Wizard.
* @param {nlobjRequest} request Request object
* @param {nlobjResponse} response Response object
* @returns {Void} Any output is written via response object
*/
function main(request, response) {
var assistant = nlapiCreateAssistant("File Upload Wizard", true);
assistant.setOrdered(true);
@benjsicam
benjsicam / netsuite_file_upload_wizard_css.js
Last active December 28, 2023 00:00
This code is a NetSuite Wizard or NetSuite Assistant which has a File Upload functionality.
/**
* Executes when the wizard page loads. Binds a function/callback on the Browse button.
* @returns {Void}
*/
function onPageInit() {
var fileUploadButton = jQuery('#browse');
if (fileUploadButton.length == 0) return;
@benjsicam
benjsicam / netsuite_file_upload_suitelet.js
Last active December 28, 2023 00:00
This code is the File Upload Suitelet for the NetSuite Wizard or NetSuite Assistant which has a File Upload functionality.
/**
* File Upload Suitelet.
* @param {nlobjRequest} request Request object
* @param {nlobjResponse} response Response object
* @returns {Void} Any output is written via response object
*/
function main(request, response) {
if (request.getMethod() == 'GET') {
/* Build the upload form. */