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
Roberto NistiRoberto Nisti 

OnCLick Javascirpt get geolocation

Hi,

   I try to get geolocation when I click on button. I Try it:

{!REQUIRESCRIPT("/soap/ajax/44.0/connection.js")}

var options = {
  enableHighAccuracy: true,
  timeout: 5000,
  maximumAge: 0
};

function success(pos) {
  var crd = pos.coords;

   {!Contact.MailingLatitude} =  crd.latitude;
    {!Contact.MailingLongitude} = crd.longitude);
};

function error(err) {
  console.warn('ERROR(' + err.code + '): ' + err.message);
};

navigator.geolocation.getCurrentPosition(success, error, options);

But, when a check the syntax, show me this error:

<span class="errorStyle">Error: The Name field is required.</span>
Raj VakatiRaj Vakati
Looks like its not code .. The Name field is required .. You have to enter the name fields firrst and save the record and then click on this button yo get the geolocation