Function: addressautoresolver.lookupAndParsePostalCode
Since Version: 1
Looks up a zip or postal code and parses the result to populate fields on the a record.
addressautoresolver.lookupAndParsePostalCode (
recType,
recId,
pCode,
fields,
conditions,
distances
)
The Zoho CRM API name for the record type that will receive field updates (i.e., "Contacts", "Leads", etc).
The ID of the destination record that will receive the field updates.
The zip or postal code that you want to resolve. For US addresses, this is the five digit zip code. US Zip+4 codes are not yet supported.
Map of Zoho field API names to field names returned from the lookup. Takes the form of Zoho_Field = Result_Field. Required.
Valid result field names are:
In addition to the standard fields, you can also use the results of the distances found to the distances value. All distance results are returned in order of nearest to furthest, so distance #1 will be the closest. To map the data returned in distances you reference the location number in the map: distance_[x]_[field_name]. Fields you can use are:
If you provide a distance index (x) that is out of bounds then the highest index item will be returned. For example, if you have 3 locations and ask for "distance_10_miles" the returned value will be from "distance_3_miles".
User fields passed will always be returned with all spaces converted to underscores and all field names in lowercase. I.e., "Sales Person Name" will return as "distance_[x]_sales_person_name".
Deluge Map Example:
fields = Map(); fields.put("Mailing_City","base_city"); fields.put("Mailing_State","base_state_province"); fields.put("Closest_Office_Distance","distance_1_miles"); fields.put("Closest_Office","distance_1_name");
The conditions in which the lookup will be performed or field updated. Takes the form of Zoho_Field = Condition. If null is passed as the map or an empty map is passed then no conditions will be applied and all fields in the fields map will be updated.
Valid condition names are:
Deluge Map Example:
conditions = Map(); conditions.put("Mailing_City","onlyifempty");
If you want to retrieve distances to the pCode's central location then you can create a map of locations to resolve. If the value passed is null or an empty map then no distances will be calculated.
The Deluge map may include three values:
If any other fields are passed in addition to longitude, latitude or zip_postal then those fields will be returned as user defined fields in the result. If you don't have enough distance licenses to resolve all locations passed then the first X locations in your list of locations will be used, where X represents the licenses you have.
Deluge Map and List Example:
offices = List(); office1 = Map(); office1.put("zip_postal", "90210"); office1.put("Name", "Beverly Hills Office"); office1.put("Sales_Person_Name", "Jill Evans"); offices.add(office1); office2 = Map(); office2.put("latitude", "39.696254"); office2.put("longitude", "-105.034428"); office2.put("Name", "Denver Office"); office2.put("Sales_Person_Name", "William Johnston"); offices.add(office2); office3 = Map(); office3.put("zip_postal", "M2K 1W9"); office3.put("Name", "Toronto Office"); office3.put("Sales_Person_Name", "Evan Delrude"); offices.add(office3); locations = Map(); locations.put("max_distance", 25); locations.put("max_count", 3); locations.put("locations", offices);