Back to Blogs
NetSuite Diaries

From Concept to Sample: NetSuite Address Auto-Complete Using Google Places

Vanessa Sampang
August 29, 2024
2 minutes
minutes to read

Exploring Address Auto-Complete

We recently stumbled upon a post about address auto-complete and thought it would be a great side project to dive into. We decided to build a custom integration for NetSuite using Google Places API, and here's how it all came together.

Getting Started with Google Places API

To integrate address auto-complete into NetSuite, the first step was to access Google’s location services. This involved obtaining an API key from Google Places. Here’s a brief overview of the process:

        1. Create a Google Cloud Project: A new project was set up in the Google Cloud Console.

        2. Enable Places API: The Places API was enabled in the API & Services section of the console.

         3. Generate an API Key: An API key was generated to authenticate requests.

With the API key obtained, integration with NetSuite could proceed.

Building the Client Script

A simple client script was created to connect NetSuite with the Google Places API. The process included:

         1. Write the Code: Include the Google Places API script tag in the file, and define the targeted fields for the action.

          <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?libraries=places&key=API_KEY"></script>

        2. Deployment: The script was attached to the relevant NetSuite forms where address input was required.

netsuite-address-auto-complete

Flexible Field Mapping

While hard-coding native address fields like Address 1 & 2, City, State, and ZIP is practical, as these are standard across many forms, a JSON mapping approach was implemented to handle custom fields more flexibly. This setup allows you to define which fields should be targeted, making it easy to adapt the script for unique or custom forms without changing the core code.

{
   "address1": "addr1", // ID of the Address 1 field
   "address2": "addr2", // ID of the Address 2 field
   "city": "city", // ID of the City field
   "state": "state", // ID of the State field
   "zip": "zip", // ID of the ZIP field
}

Drive Efficiency with NetSuite Address Auto-Complete

This solution effectively enhances the address entry process in NetSuite by leveraging the Google Places API. By implementing a client script with flexible field mapping, the feature accommodates both standard and custom forms, making it a versatile and user-friendly addition. The successful integration aims to improve accuracy and efficiency in address handling, ultimately providing a better experience for users.

At ATSOURCE, we support our developers in delivering effective solutions. Should you be curious about how this was developed or interested in similar projects, get in touch. It’d be great to chat about it.

Meet the Author

With over a decade of hands-on experience in NetSuite development, Vanessa has worked with global NetSuite partners and end-users, specializing in implementation, integration, administration, and support. She has also mentored fellow NetSuite developers during her consulting career. In 2015, Vanessa co-founded CloudCompass Technologies, an independent NetSuite practice focusing on managed services.