Calculate the difference between 2 addresses

Hi,

I'm looking to add a filed to the account called distance and calculate the distance between the account address and the sales rep's address. 

How can I use a Geocoding Service. Is it possible? I never used an API with Creatio, would love to get a documentation or any information that can help.

Thanks,

Chani

Like 0

Like

3 comments

Hello,

 

When entering an address, you can specify the coordinates manually. Additionally, they are recorded automatically if the address is identified.
Have you considered calculating the distance using the coordinates of two points?
This way you can use the logic utilized in the check-in for the mobile app.

Mira Dmitruk,

Thanks for your answer.

Can you please provide more info?

I see the GPS N and the GPS E fields on the account but they always blank. I do not expect my users to know these values. 

What do you mean when you say: they are recorded automatically if the address is identified? How can the address be identified? 

Hello!

In the Creatio mobile application, there is built-in logic that calculates the distance between the user's current location and the coordinates specified in the account record. This functionality is used primarily in the "Check-In" feature available in mobile scenarios (such as field sales).

How it works:

  1. The mobile app retrieves the device's current location using the geolocation plugin (Cordova-based), which accesses the GPS hardware of the device. It uses standard JavaScript methods like navigator.geolocation.getCurrentPosition() to get the latitude and longitude of the user.
  2. The system reads the GPS coordinates stored in the account's fields GPSN (latitude) and GPSE (longitude). These coordinates must be pre-populated manually or via integration with a geocoding service.
  3. The app calculates the distance between the two locations using the Haversine formula. This formula returns the great-circle distance between two sets of coordinates in kilometers or meters.
  4. The result is compared against a configured distance threshold (for example, 500 meters). If the user is within this range, the check-in is allowed. If the user is too far from the account's location, the check-in is blocked.

This logic is implemented entirely on the client side (within the mobile app). It does not require a server call or integration during the check-in attempt.

Technical implementation is located in mobile modules such as:

  • MobileActivityVisitAddFeature
  • MobileLocationUtilities
  • VisitHelper.js
  • Terrasoft.sdk.utils.Location
Show all comments