Browsed by
Category: Netsuite Tips

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:

 

Suitescript 2.0 SFTP Tool

Suitescript 2.0 SFTP Tool

One of the new features of SuiteScript API 2016.2 is the ability to connect to SFTP Servers directly from Netsuite.

Here are some downsides I found:

  • Not way to list the contents of a remote directory
  • No way of connecting using a private key.
  • Not all SFTP servers are supported as Netsuite requires the server to support some encryption algorithms.
  • No way of obtaining the server’s hostkey natively.

 

Unfortunately the process is a bit confusing if you are new to the SFTP world so I created a tool that will help you jump-start your script. I found this tool very useful as I was able to test an SFTP connection quickly for a client and turned out the SFTP server that they were trying to use didn’t actually support Netsuite’s approved algorithms (aes256-ctr, es192-ctr, es128-ctr), so it saved me a lot of time as I was able to quickly discard it and move on.

I also included an endpoint to get the HostKey of the URL you are trying to connect to. I think this will be very useful for people who don’t have a Linux server lying around where they can run ssh keyscan.

Note: The HostKey endpoint should be used to grab the hostkey and store it elsewhere on your end. Do not use the endpoint to request the hostkey every time you make a request. If your server HostKey changes very frequently then I suggest to build your own tool.

Here’s a video tutorial:

 

And here’s the code ready to be uploaded as a Suitelet, have fun!: