My client is looking to add a functionality that will allow Zoho inventory to automatically update the City, State and Country fields on a customer record based on a zip code that they've entered. For example - if they enter 92705 as a zip code (US zipe code) the system will automatically update the following: City: Santa Ana, State: California, Country: United States
I was able to write a custom function that looks at the customer record, and calls the google maps API to retrieve the City, State and Country. I'm able to retreive the data i need from google maps API but running into an issue when trying to take the values i retrieved and update the customer shipping address. Below is the code i've used which doesn't work:
city = address.get(1).getJSON("long_name");
//parsing the Jason I received from google
state =
address.get(3).getJSON("long_name"); //parsing the Jason I
received from google
country =
address.get(4).getJSON("long_name"); //parsing the Jason I received
from google
mp = Map(); //declaring the response variable
mp.put("shipping_address[city]",city);
mp.put("shipping_address[state]",state);
mp.put("shipping_address[country]",country);
update =
zoho.inventory.updateRecord("Contacts",organizationID,customerID,mp);
Looking at the JSON format I get using the GET command for a customer it seems like Shipping_address is on a nested level in the JSON (see attached file). I'm trying to figure out the correct syntax to update the shipping address. Any guidance/direction will be much appreciated!