NetSuite / SuiteScript: Getting A Remote IP Address

Published on May 24, 2019

I'm currently working on a NetSuite integration project, and in one of the Suitelets, I need to get the remote IP address of the user or client.

An easy way to get the value is via the request headers. For example:

var ip = context.request.headers['ns-client-ip'];

There are several other interesting and potentially useful headers that are available, including the the user-agent (ex: "Mozilla/5.0"), the NetSuite host (ex: "startron11.extforms.netsuite.com"), and so on. To get a sense of what's available, log the headers, like this...

log.debug( { title: 'Headers', details: context.request.headers } );

Then review the script's Execution Log.