Formula field

Formula field

Hi,
I am trying to automatically calculate the distance between to points by using the "formula field".

The javascript for the calculation is this:



var R = 6371; // km var dLat = (lat2-lat1).toRad(); var dLon = (lon2-lon1).toRad(); var lat1 = lat1.toRad(); var lat2 = lat2.toRad(); var a = Math.sin(dLat/2) * Math.sin(dLat/2) + Math.sin(dLon/2) * Math.sin(dLon/2) * Math.cos(lat1) * Math.cos(lat2); var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); var d = R * c;

But i can not make it work. I suspect that the "formula field" does not support mathematical values such as sin and con.

Is that correct understood?




Is there another way of using a javascript to calculate the value of a CRM field?

Kind regards,
Bo Thygesen