Skip to main content
Bob Delaney 님이 #Data Management에 질문했습니다
Hi- trying new code to do this and the field Current_Latitude (Fieldname) is not updating.  Any ideas?  No errors are thrown

 

 

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

var UpdateLatitude= prompt ("Please enter the Latitude to calculate Distance");

var newRecords = [];

var o = new sforce.SObject("Account");

o.Current_latitude__c = UpdateLatitude;

newRecords.push(o);

result = sforce.connection.update(newRecords);

alert("The new latitude is entered")

window.location.reload();

 

 
답변 2개
  1. 2016년 10월 11일 오전 4:48
    Hi,

     

    You need to take care of couple of things, as this is list view button you need to pass the list or single record for update,

     

    Also Geolocation field work diffferntly in API : Read and set geolocation field components by appending “__latitude__s” or “__longitude__s” to the field name, instead of the usual “__c.”

     

     

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

    var records = {!GETRECORDIDS($ObjectType.Account)};

    var updateRecords = [];

    if (records[0] == null)

    {

    alert("Please select at least one Account")

    }

    else

    {

    var UpdateLatitude= prompt ("Please enter the Latitude to calculate Distance, Must be within -90 and 90");

    var UpdateLongitude= prompt ("Please enter the Longitude to calculate Distance, Must be within -180 and 180");

    for (var i=0; i<records.length; i++)

    {

    var acc = new sforce.SObject("Account");

    acc.id = records[i];

    acc.Current_latitude__latitude__s = UpdateLatitude;

    acc.Current_latitude__longitude__s = UpdateLongitude;

    updateRecords.push(acc);

    }

    result = sforce.connection.update(updateRecords);

    alert("The new latitude is entered")

    window.location.href = "/001";

    }

     

    This Answers Community is focused on configuration and design questions. Programmatic questions are best submitted to the developer forums at https://developer.salesforce.com where the forums and participants are geared toward programming troubleshooting and support.

     

    Hope this helps !!

     

    --

     

    Thanks,

     

    Swayam
0/9000