function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Santro652Santro652 

Distance calculator

Hi,

 

I am using professional edition, and my customer has the following requirement: When any user does any service call then the user should enter the location from where he travelled From and To and the distance should get auto calculate. Does any one have any idea how I can create the same or any App exchane App. Help is appreciated.

 

Ex: Location

From: X

To: Y

Distance: (The system calculates the distance depending on the location name entered in X and Y)

Ankit AroraAnkit Arora

You just need to create a formula field on your object. Which will look something like this :

 

 

IF(!NOT(ISNULL(Distance1_API__c)) && NOT(ISNULL(Distance2_API__c)) , (Distance1_API__c - Distance2_API__c) , 0)

 

 

Just replace API names with your own and try to run this, hope this will work.

 

How to create formula field : Go To your object from setup > Create New Field(Formula).

 

 

Thanks
Ankit Arora

 

Santro652Santro652

Hi,

 

can you please explain in description how I can go about this, as this is something new.

 

Appreciate your help.

Ankit AroraAnkit Arora

Just click on Setup > App Setup > Go TO your Object > Create new field > Select Formula > Provide Name > Return Type number > Copy Paste the above code > Replace Distance_API__c with your distance field API names > Save the field.

 

Now what exactly this validation do is, will check that both the distance fields are not null. If both fields have value then it will provide the difference between both. If both fields are null then it will return 0.

 

 

Thanks
Ankit Arora

 

Santro652Santro652

I think we are slightly off track:

 

Example: There are three fields in salesforce To,From and Distance

 

In the To field i enter: M.GRoad(Location Name)

From: Residency Road(Loacation Name)

Distance: 4Km(System should pull the distance from google maps and paste it in this field)