Skip to content

Instantly share code, notes, and snippets.

View W3BGUY's full-sized avatar
🤐
Burnt Out

w3bguy W3BGUY

🤐
Burnt Out
View GitHub Profile
@W3BGUY
W3BGUY / 0_reuse_code.js
Last active September 2, 2015 11:52
Here are some things you can do with Gists in GistBox.
// 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 02:22
JitterBit Conversion for Country Code in NetSuite AddressBook
<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 November 17, 2016 14:20
JitterBit Conversion for Country To Country Code in Salesforce
<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 / NetSuite_2.0_InventoryItemSearch.js
Last active January 25, 2023 15:20
NetSuite SuiteScript 2.0 - Search for Inventory Items and return an array of all active items.
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 / NetSuite_2.0_Scheduled_Script_Set_Percent_Complete.js
Last active January 25, 2023 15:20
NetSuite SuiteScript 2.0 - Set Scheduled Script Percent Complete
/**
* @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 September 8, 2016 17:17
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.
<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 April 21, 2021 15:10
NetSuite - Convert Date Object into NetSuite usable Date Format
// 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 November 16, 2016 16:01
NetSuite - Convert Date Object into NetSuite usable Datetime Format
// 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 November 16, 2016 15:58
NetSuite Get Number of Days in Month
// 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 November 16, 2016 18:17
JitterBit - Remove all non-numeric characters from string
//Simple way to remove all non-numeric characters from a string, in JitterBit
$phone=RegExReplace($phone,"(\\D)","");