Previous Topic

Next Topic

Book Contents

Book Index

Accredo Sales App Geocoding

You can set up Accredo to apply geocoding to customers when you save them.

Geocoding is set up via scripting. You will need a Google Maps API Key, and you will need to set up the Company.OnMap and Company.OnGeoCode script events as described in Geocode Script Editor.

To have Geocoding applied to customers via the Sales App, you will need to write code to do this in the ARCustomerData.BeforeSave script.

The following is an example of code to apply geocoding to customer delivery address before they are saved.

Dim ARCust as Object

ARCust = GetTriggerObject

Dim ARAddress as Object

ARAddress = ARCust.DeliveryAddress

Try

  ARCust.Edit

  ARAddress.First

  Do Until ARAddress.EOF

    If ARAddress.DeliveryAddress1 <> "" Then

      Try

        ARAddress.Edit

        ARAddress.Geocode

        ARAddress.Save

      Catch ex

        If ARAddress.Editing Then ARAddress.Cancel

      End Try

    End If

    ARAddress.Next

  Loop

  ARCust.Geocode

  ARCust.Save 

Catch ex

  If ARCust.Editing Then ARAddress.Cancel

End Try

Note: If you already have a ARCustomerData.BeforeSave script, you will need to integrate this code into the existing script.

If you have Customers with a large number of delivery addresses, this can cause a delay when saving customer details.