Browsed by
Category: Netsuite Tips

Getting Item Earliest Available Date Programatically

Getting Item Earliest Available Date Programatically

I was browsing through the Netsuite user group and I stumbled upon this interesting question:

I have a client that wants to automate the process of checking/calculating the ‘Earliest Available Date’ from the ‘Check Item Availability’ feature on the item level of a sales order. I know that this calculation is done using the ATP lead time, but I am not sure how to initiate this calculation via SuiteScript or Saved Search. I have shown this issue to NetSuite support and they told me that it is not currently possible to access the “Earliest Available Date” by either Saved Search or API. It literally requires someone to click the “Check Item Availability” which loads the popup dialog and shows the date. My client would obviously like to avoid having to drill into every sales order and check this date.
 
Does anyone know of a way to display the ‘Earliest available date’ via Saved Search or API? Or many another way to calculate it via some other ATP lead time calculation.

I was able to reverse engineer the process that Netsuite uses to calculate the “Earliest Available date” and I came up with a solution that works within the browser console. The solution loads the popup in the back, parses the HTML and gets the data. This may help you get started on designing a more robust solution.

Here’s a sample output:

Here’s the code ready to run in the browser console:

Note: Since this is running in the browser you might need to play around with the script to get over 100 items at a time as the governance would run out. Alternatively you could use an Ajax call instead of nlapiRequestURL.

 

Convert Salesforce Ids from 15 to 18 characters using Javascript

Convert Salesforce Ids from 15 to 18 characters using Javascript

I figured this will be useful for anybody working with Salesforce. I used this within Netsuite and worked beautifully.

Here’s the code:

 

Free Automatic Translation Within Netsuite using Yandex Translate API

Free Automatic Translation Within Netsuite using Yandex Translate API

In this challenge I decided to integrate Netsuite with Yandex Translate REST API for the following reasons:

  • Free version includes:
    • Up to 10 million characters a month (or 322,580 characters per day spread evenly in 31 days)
    • Up to 1 million characters in 24 hours (would last 10 days only as max is 10 million per month)
    • Translation quality is decent.
    • Great for small translation projects.

Let’s say we want to translate a FreeText field, that has a max of 300 characters so that would allow me for a max workload of around 1,075 translations per day, and that’s maxing out all 300 characters per request. Not bad.

Getting started is really easy:

  1. Go to https://tech.yandex.com/translate/
  2. Get a free API Key (You might need to register)
  3. Call the Yandex API within Netuiste (Follow the code example below)

I tested this on an after submit script that translates the memo field and saves the result in another field called “Memo in Spanish”

yandexexample

Don’t forget to check Yandex Translate API documentation to learn more about the languages and more features such as auto detecting languages.

Here’s the code example: