Scenario: Automatically populate the State, City and Country based on the ZIP code (only for US)
When a contact, lead or an account is created, you have to fill in the address details manually.
You can save time by populating the value for State, City and Country based on the ZIP code you enter. You just need to enter the ZIP code and the rest will be populated automatically.
Right now, we have done this custom function only for United States ZIP code.
Please follow these steps:
Deluge Script:
void workflowspace.Auto_State_City(string leadId,string zipcode)
{
pinresp=((getUrl("http://zipfeeder.us/zip?key=<zipfeederAPIKEY>&zips=" + input.zipcode))).toString();//Calling
zipfeeder api to get the information
state = pinresp.executeXPath("/root/zips/state/text()");//Getting State info from the zipfeeder response
city = pinresp.executeXPath("/root/zips/city/text()");//Getting city info from the zipfeeder response
county = pinresp.executeXPath("/root/zips/county/text()");//Getting city info from the zipfeeder response
upresp = zoho.crm.updateRecord("Leads",input.leadId,{ "State" : state, "City" :
city,"Country":"USA","County":county});//updating zohocrm lead
}
Note: This custom function is for the Leads module and this can be used in any module where you want to automatically populate the State, City and Country information based on the Zip Code. You just need to modify the module name and field names in the custom function.
Please refer to the following link to know more about this feature:
https://www.zoho.com/crm/help/automation/custom-functions.html