I'm starting out using the enterprise API for PHP with a simple create command...

$createResponse = $mySforceConnection->create($insertArray, 'customobject__c');

My $insertArray includes a value to go into the custom objects geocode field.

The problem is that i'm simply now sure how to format the two lat/lng values I have and whatever I try results in the following error

Unable to create/update fields: Location__c. Please check the security settings of this field and verify that it is read/write for your profile or permission set.

Btw, I'm sure this is nothing to do with security as I had the same error on other fields that were simply miss-formatted.


You need to set the latitude and longitude separately; the main field is a compound field that can only be read, similar to how Account.ShippingAddress combines all of the address fields.


customobject__c.Location__latitude__s = latitude
customobject__c.Location__longitude__s = longitude

More information can be found in the documentation for the Geolocation Compound Field.

  • Thanks @Mike Chale, one thing, what would the format be in PHP? I'm submitting via an array that is being compiled and full stops are not valid syntax. Ie $insertArray[0]->Location__c.Location__latitude__s = $locationLat; I can't find an example anywhere showing this... – AdamJones Oct 15 '15 at 19:13
  • I'm not terribly familiar with PHP, but I think it'd be $insertArray[0]=>Array([Field1]=>value1, [Field2]=>value2, . . .) – Mike Chale Oct 15 '15 at 19:27
  • It works as standard without square brackets, but either way, with or without them, adding a full stop is invalid syntax. – AdamJones Oct 15 '15 at 19:32
  • You need to convert it to valid PHP; the example above was meant as a generic sample of how to use the fields. – Mike Chale Oct 15 '15 at 19:41
  • I understood that, I'm just expressing I don't know the PHP syntax but I'm working on that now... – AdamJones Oct 15 '15 at 19:43

So @Mike Chale gave me the key piece of info that the geolocation field is a compound field. The syntax I need is different though as this is the custom geolocation field.


Unlike all my other custom fields that are suffixed with __C, this doesn't need that although it is a custom field and __latitude__s or __longitude__s is suffixed instead.

More info here: https://help.salesforce.com/apex/HTViewHelpDoc?id=custom_field_geolocate_overview.htm&language=en

  • 1
    He took the time to answer your question, show the same etiquette and mark his answer as correct, adding any additional information to his answer. – Brian Mansfield Oct 15 '15 at 20:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.