Skip to content

Instantly share code, notes, and snippets.

Avatar
🤐
Burnt Out

Charles Bastian W3BGUY

🤐
Burnt Out
View GitHub Profile
@W3BGUY
W3BGUY / 0_reuse_code.js
Last active Sep 2, 2015
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@W3BGUY
W3BGUY / jitterbit_Salesforce_to_NetSuite_Country_Conversion.js
Last active May 7, 2019
JitterBit Conversion for Country Code in NetSuite AddressBook
View jitterbit_Salesforce_to_NetSuite_Country_Conversion.js
<trans>
$contact_country=CASE(
$contact_countryShort=="AF","_afghanistan",
$contact_countryShort=="AX","_alandIslands",
$contact_countryShort=="AL","_albania",
$contact_countryShort=="DZ","_algeria",
$contact_countryShort=="AS","_americanSamoa",
$contact_countryShort=="AD","_andorra",
$contact_countryShort=="AO","_angola",
$contact_countryShort=="AI","_anguilla",
@W3BGUY
W3BGUY / jitterbit_Salesforce_Country_Conversion.js
Last active Nov 17, 2016
JitterBit Conversion for Country To Country Code in Salesforce
View jitterbit_Salesforce_Country_Conversion.js
<trans>
thisState=case(
thisState=='Alabama','AL',
thisState=='Alaska','AK',
thisState=='Arizona','AZ',
thisState=='Arkansas','AR',
thisState=='California','CA',
thisState=='Colorado','CO',
thisState=='Connecticut','CT',
thisState=='Delaware','DE',
@W3BGUY
W3BGUY / NS2.0_InventoryItemSearch.js
Created Jun 30, 2016
NetSuite SuiteScript 2.0 - Search for Inventory Items and return an array of all active items.
View NS2.0_InventoryItemSearch.js
require(['N/search','N/record'],function(search,record){
function buildItemArray(){
var itemArray=[];
searchItems();
itemArray=runSearch(itemArray);
deleteSearch();
log.debug(itemArray);
}
function searchItems(context){
@W3BGUY
W3BGUY / NS2.0_SCH_Set_Percent_Complete.js
Created Aug 22, 2016
NetSuite SuiteScript 2.0 - Set Scheduled Script Percent Complete
View NS2.0_SCH_Set_Percent_Complete.js
/**
* @NApiVersion 2.x
* @NScriptType ScheduledScript
* @NModuleScope SameAccount
*
* According to the documentation this is a read-only field. According to this working code and a verification from
* NetSuite tech support, the documentation is wrong. Hope this helps someone out.
*
*/
define(['N/runtime','N/record'],function(runtime,record){
@W3BGUY
W3BGUY / JitterBit_Check_For_Queued_Operations.txt
Created Sep 8, 2016
JitterBit Script to check for running operations. If operations are not currently running, start operation. This works very well when dealing with scheduled scripts that may overlap.
View JitterBit_Check_For_Queued_Operations.txt
<trans>
$isInQueue=GetOperationQueue("<TAG>Operations/OperationToCheck01</TAG>");
$isInQueue2=GetOperationQueue("<TAG>Operations/OperationToCheck02</TAG>");
$isRunning=$isInQueue[0][1];
$isRunning2=$isInQueue2[0][1];
if(($isRunning==1 && $isRunning!=Null()) || ($isRunning2==1 && $isRunning2!=Null()),
WriteToOperationLog("Skip for now: "+$isRunning+" / "+$isRunning2);,
WriteToOperationLog("Nothign is Running - Starting Operation Chain.");
RunOperation("<TAG>Operations/OperationToCheck01</TAG>");
);
@W3BGUY
W3BGUY / NetSuite_Convert_Date_Obj_To_NS_Date.js
Last active Nov 16, 2016
NetSuite - Convert Date Object into NetSuite usable Date Format
View NetSuite_Convert_Date_Obj_To_NS_Date.js
// function to add leading zeros on date parts.
function zeroPad(num,len){
var str=num.toString();
while(str.length<len){str='0'+str;}
return str;
}
// function to format date object into NetSuite's mm/dd/yyyy format.
function formatNSDate(dateObj){
if(dateObj){
@W3BGUY
W3BGUY / NetSuite_Convert_Date_Obj_To_NS_Datetime.js
Last active Nov 16, 2016
NetSuite - Convert Date Object into NetSuite usable Datetime Format
View NetSuite_Convert_Date_Obj_To_NS_Datetime.js
// function to add leading zeros on date parts.
function zeroPad(num,len){
var str=num.toString();
while(str.length<len){str='0'+str;}
return str;
}
// function to format date object into NetSuite's mm/dd/yyyy HH:MM:SS format.
function formatNSDateTime(dateObj){
if(dateObj){
@W3BGUY
W3BGUY / NetSuite_Get_Number_Of_Days_In_Month.js
Created Nov 16, 2016
NetSuite Get Number of Days in Month
View NetSuite_Get_Number_Of_Days_In_Month.js
// function to figure out the number of days in month.
function getDaysInMonth(thisMonth,thisYear){
var monthArray=[31,28,31,30,31,30,31,31,30,31,30,31];
if(thisMonth!=2){return monthArray[thisMonth-1]};
if(thisYear%4!=0){return monthArray[1]};
if(thisYear%100==0 && thisYear%400!=0){return monthArray[1]};
return monthArray[1]+1;
}
// NetSuite usage example
@W3BGUY
W3BGUY / JitterBit-Remove_Non-Numeric
Created Nov 16, 2016
JitterBit - Remove all non-numeric characters from string
View JitterBit-Remove_Non-Numeric
//Simple way to remove all non-numeric characters from a string, in JitterBit
$phone=RegExReplace($phone,"(\\D)","");