Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

NetSuite – SuiteScript 2.0 – Useful Functions

Posted on August 31, 2018 By David Kittell

These first function snippets are from https://gist.github.com/W3BGUY

/**
 * @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){
  return {
    execute:function(context){
      var script=runtime.getCurrentScript();
      for(x=0;x<500;x++){
        var rec=record.create({type:'salesorder'});
        script.percentComplete=(x*100)/500;                               
      }
    }
  };
});
require(['N/search','N/record'],function(search,record){
  function buildItemArray(){
    var itemArray=[];
    searchItems();
    itemArray=runSearch(itemArray);
    deleteSearch();
    log.debug(itemArray);
  }
  
  function searchItems(context){
    var itemSearch=search.create({
      type:search.Type.INVENTORY_ITEM,
      title:'Inventory_Item_Search',
      id:'customsearch_inventory_item_search',
      columns:['internalid','itemid'],
      filters:['isinactive','is','F']
    });
    itemSearch.save();
  }
  
  function runSearch(itemArray){
    var mySearch=search.load({id:'customsearch_inventory_item_search'});
    mySearch.run().each(function(result){
      var item={};
      item.itemID=result.getValue({name:'itemid'});
      item.internalID=result.getValue({name:'internalid'});
      itemArray.push(item);
      return true;
    });
    return itemArray;
  }
  
  function deleteSearch(){
    search.delete({id:'customsearch_inventory_item_search'});
  }
  
  buildItemArray();
});
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

Code NetSuite SuiteScript 2.0

Post navigation

Previous post
Next post

Related Posts

LDAP Dates Converted

Posted on July 25, 2013October 26, 2015

Dates that look like 127524839567199000 (pwdLastSet, accountExpires, lastLogonTimestamp, etc.) IF( B16>0 ,B16/864000000000 – 109205 ,"" ) Example: 130186556607343750 converts to 40921.80861 40921.80861 in Excel with cell formatting of Date/Time will show as January 13th, 2012 7:24 PM Dates that look like 20050210223453.0Z (whenChanged) DATEVALUE( CONCATENATE( (LEFT(TRIM(B9),4)) ,"-" ,(RIGHT(LEFT(TRIM(B9),6),2)) ,"-" ,RIGHT(LEFT(TRIM(B9),8),2)…

Read More

Ubuntu – Send Notification To All Users

Posted on November 10, 2017February 2, 2018

This script has only been tested on Ubuntu based OS but is possible it will work on other builds #!/bin/sh # NotificationAssistant.sh # # # Created by David Kittell on 11/10/17. # notify_all() { icon=$1 # Review lists in /usr/share/icons/gnome/32×32 or /usr/share/notify-osd/icons title=$2 # Bolded notification title msg=$3 # Actual…

Read More

PHP – Latitude Latitude to Maidenhead Grid – HAM Radio

Posted on June 14, 2020August 17, 2024

Recently I was asked by a HAM Radio friend to work on a conversion of latitude and longitude coordinates to maidenhead grid. The code below is in “rough” PHP code on purpose to help illustrate the math behind the conversion. Feel free to clean/optimize it all I ask is that…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • Front Page
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions
  • Open On Screen Keyboard (OSK)
  • SQLite - Auto-Increment / Auto Generate GUID
©2025 David Kittell | WordPress Theme by SuperbThemes
 

Loading Comments...
 

You must be logged in to post a comment.